second question. No idea how to implement in O(1) time.
Anonymous
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).
Check out your Company Bowl for anonymous work chats.