Dsa
Intervals
Medium
Employee Shift Scheduling
You are tasked with scheduling employee shifts based on their availability. Each employee has a range during which they can work, defined by start and end times. Your goal is to determine how many employees can be assigned to shifts without overlapping their available times.
Input format: The first line contains an integer n (1 <= n <= 1000), the number of employees. The next n lines each contain two integers representing the available start and end times of each employee (0 <= start < end <= 24).
Output format: Print a single integer, the maximum number of employees that can be assigned shifts without overlap.
Example:
Input:
4
1 4
2 5
3 6
4 7
Output:
2
Key concepts
intervalsschedulinggreedy
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