Dsa
Greedy
Medium
Maximize Gift Receivers with Minimum Overlap
A charity organization is distributing a limited number of gifts across multiple events. Each event has a designated start and end time, and a certain number of gifts to be given away. However, an event cannot accept gifts from another event that overlaps with it. Your task is to maximize the number of gift receivers at different events while obeying the non-overlapping condition. Given the events and their respective gift quantities, return the maximum number of gift receivers that can be achieved across events.
Input Format:
- The first line contains an integer n (1 ≤ n ≤ 100) - the total number of events.
- The following n lines each contain an integer representing the start time and the number of gifts available at that event.
Output Format:
- A single integer - the maximum number of gift receivers without overlap.
Example:
Input:
5
1 2
2 1
3 3
4 1
6 1
Output:
7
Key concepts
greedyintervalscombinatorics
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now