Spotnana interview question

Question related to priority queue and DP