Pergunta de entrevista da empresa Point72

Solve a greedy algorithm coding question.