Google interview question

Greedy Approach question that is in leetcode.