Dsa
Intervals
Easy
Peak Lock Contention
A database system tracks resource locks. Each lock is active during the interval [start, end). You are given N lock intervals. Find the maximum number of concurrent locks active at any single point in time.
Input Format:
The first line contains N.
The next N lines each contain start and end.
Output Format:
Print the maximum overlap count.
Example:
Input:
3
1 5
2 6
3 7
Output:
3
Explanation: Between time 3 and 5, all three locks are active.
Key concepts
intervalssweep-lineprefix-sum
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