Skip to content

Instantly share code, notes, and snippets.

@biplav
biplav / max_section.py
Last active August 29, 2015 14:15
Zopper interview programming question on HackerEarth. Question 1 Description available at: http://censore.blogspot.in/2015/02/zappos-online-assesment-question-on.html while Question 2 description is available at http://censore.blogspot.in/2015/02/zopper-programming-assessment-problem-2.html
MAX_ROW=500
MAX_COL=500
def assign_walls(row,col):
w = raw_input()
inp = w.split(" ")
if inp[0] is 'C':
col.append(int(inp[1]))
else:
@biplav
biplav / Analysis
Created May 20, 2014 11:07
Write a program, topN, that given an arbitrarily large file and a number, N, containing individual numbers on each line (e.g. 200Gb file), will output the largest N numbers, highest first. Tell me about the run time/space complexity of it, and whether you think there's room for improvement in your approach
The current approach will have complexity of KO(logN) where K is the number of lines in the file supplied. This complexity can be further improved if i know the range of the numbers which can be supplied. If the range is much less then K, then a different algorithm can be applied which should possibly reduce the complexity to K.
@biplav
biplav / ArrayUtils.java
Created May 20, 2014 10:55
Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]
package com.intercom.biplav.flatten;
import java.util.LinkedList;
import java.util.List;
public class ArrayUtils {
private void flatten(Object[] toflatten, List<Object> flat) throws Exception {
for(Object each: toflatten) {
if(each instanceof Object[]) {