Google interview question

Q was based on 2 heaps