Dsa
Intervals
Hard
Longest Non-overlapping Intervals
Given a list of intervals, determine the longest set of non-overlapping intervals. Each interval will be represented in the format 'start-end'. Write a program that outputs the longest set of intervals as a space-separated string. Example: '1-3 2-5 4-6' should return '1-3 4-6'.
Key concepts
intervalsdynamic programminggreedy
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