Pergunta de entrevista da empresa Swiggy

Question related to greedy algorithm.