Two sigma questions from Head Hunter
Sort a list of words and integers and keep the relative order of words and integers, plus your data-center screwed up and know every data center needs to have the data from the other centers again, what is the most efficient way to copy data such that every center has it.
Given a set of (start, end) pairs of timestamps where end > start, write an algorithm to return the smallest set of disjoint intervals containing every pair of (start, end) in the original set.
string compression - huffman /lempel ziv
Reg expression matching algorithm (parse string, recursion, some edge cases, check jvm implementation)
Write a program that takes a list of strings containing integers and words and returns a sorted version of the list. The goal is to sort this list in such a way that all words are in alphabetical order and all integers are in numerical order. Furthermore, if the nth element in the list is an integer it must remain an integer, and if it is a word it must remain a word.
centers using as few copies as possible. Example 1: ---------- Input: 4 1 3 4 1 2 3 1 3 1 4 2 One Possible Correct Output: 2 2 1 4 1 2 2 2 3 4 4 3 3 1 4 done
the most unexpected one was "what is Godel's incompleteness theorem?
Find all the subsets of size k
Construct tree from given array. Write a method for removing a subtree, given the root of the subtree.
How would you design a class/methods for reverse Polish notation? (They explained what reverse Polish notation was first, of course)
Design question: how could you extend your implementation of reverse Polish notation to include more operators?
Implement reverse Polish notation using only arithmetic operations
Design LRU
Design an ATM
Find max benefit from 2 transactions given some stock prices
How would you calculate the mean on a continuous stream
Write code to process multiple interleaving streams of data (from a text file) and output statistics on each stream.
For the architecture question, Conway's Game of Life algorithm was considered. I was asked to write pseudo code for tackling this problem at a micro-level (e.g. one machine) and a large-scale level (e.g. distributed system
Code a function that matches regular expressions with targets. There is a DP and a recursive solution.
postifix computer
Code a postfix notation calculator. Doable with a stack. Now, what if you wanted to support arbitrary operations on some variable number of preceding numbers? How does the code change?
You are given a tree in the form of a list of (value, parentndx, intree) tuples, where intree is a boolean denoting whether the node is in the tree, and parentndx is the location in the list of the parent node of this node. The root's parent is -1. Write a function remove(ndx) that removes the node at that ndx and all its children in O(n). It requires caching which nodes have been visited and a recursive function that checks whether a node in the list should be removed (terminates on parentndx==-1 || ndx or when it finds a cached node that was already removed and visited)
You are given two infinite streams of data, where each datum has fields (timestamp, value). The streams have a single function take() that pops the oldest thing off and returns it or "blocks" until something arrives in the queue for it to return. Data might arrive much later than its timestamp. You are given a function output(a,b), which takes two values, one from each stream, and computes something. You want to call output() on all (a,b) pairs that have timestamps less than some given interval apart, and you want to do this as soon as any data that completes such a pair arrives. Construct pseudocode that will do this. The answer involves two threads that each manage a list of numbers pulled off their stream, pull a number from the other thread's list, try to match it against everything, and then carefully discard data when appropriate
You are managing a webservice and get a complaint about the page loading slowly. What is a possible cause of the problem? How would you check that? Okay, say that's not the problem. What else could it be?
add 2 numbers without using +
Last updated