Dsa
Greedy
Easy
Wildlife Snapshot
You are setting up automated cameras to capture photos of endangered lynx. You have a list of time intervals [S[i], E[i]] when a lynx is known to be active at a watering hole. A single camera snapshot at time T captures all active lynx whose intervals include T (S[i] <= T <= E[i]). What is the minimum number of snapshots needed to capture every lynx activity at least once?
Input Format:
The first line contains N, the number of intervals. The next N lines contain two integers S[i] and E[i].
Output Format:
A single integer representing the minimum snapshots.
Example:
Input:
3
1 5
2 3
4 6
Output:
2
Explanation: A snapshot at time 3 covers [1,5] and [2,3]. A snapshot at 6 covers [4,6].
Key concepts
greedyintervalssorting
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