Pergunta de entrevista da empresa IBM

Question related to greedy algorithm