Amazon interview question

Questions Based on Trees, Heap. optimal approach was asked