MAQ Software Interview Question

Water melon problem related to priority queue