Bloomberg interview question

Greedy style leet code hard