Swiggy interview question

Question related to greedy algorithm.