Answer: Atlassian OA Question 2024 September | Intervals | on-campus
Answer · Posted Jun 2026
Solution: Non-overlapping Intervals — Greedy Sort by End Time Approach This is a classic Greedy problem. The key insight is: to minimize removals, we want to keep the maximum number of non-overlapping intervals. To do this greedily: Sort intervals by their end time. Intervals that end earliest give more room for future intervals. Use a variable prevEnd to track the end of the last kept interval. For each interval: if its start is >= prevEnd, we can keep it (update ...
The full answer & interview discussion are available to premium members.
Log in Create a free account