Amazon Interview Question

second question. No idea how to implement in O(1) time.

Interview Answers

Anonymous

Sep 3, 2014

Haven't had chance to implement the details to verify it, but I think it is actually asking for a sequence where you always put the maximum of the 4 as the first number. A maxHeap should do it in O(1).

Anonymous

Dec 17, 2014

Since the size of input is fixed, 4. Hence it has constant running time, Hence O(1)