Pergunta de entrevista da empresa Spotnana

Question related to priority queue and DP