Maximize events attended given date ranges
Company: Salesforce
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of interval scheduling and efficient algorithm design for allocating limited time-based resources, including concepts like sorting and priority handling.
Constraints
- 0 <= len(events) <= 100000
- 1 <= start_i <= end_i <= 10^9
- You can attend at most one event per day
Examples
Input: [[1,2],[2,3],[3,4]]
Expected Output: 3
Explanation: Attend the first event on day 1, the second on day 2, and the third on day 3.
Input: [[1,2],[1,2],[3,3],[1,5],[1,5]]
Expected Output: 5
Explanation: A valid schedule is days 1, 2, 3, 4, and 5 for the five events, so all events can be attended.
Input: [[1,1],[1,1],[1,1]]
Expected Output: 1
Explanation: All three events can only be attended on day 1, but only one event may be attended per day.
Input: []
Expected Output: 0
Explanation: There are no events to attend.
Input: [[5,5],[1,2],[100,100],[2,3],[2,2]]
Expected Output: 5
Explanation: One optimal schedule is day 1 for [1,2], day 2 for [2,2], day 3 for [2,3], day 5 for [5,5], and day 100 for [100,100].