Swiggy Interview Question

Question related to greedy algorithm.