DSA interview question
A single conference room has n meeting requests, each with a start and an end time. Only one meeting can use the room at a time, and a meeting can start only strictly after the previous one ends (the room needs a moment to reset). What's the maximum number of meetings that can be held? This is interval scheduling, and the classic greedy is to always pick the meeting that finishes earliest among those that fit, because finishing early leaves the most room for the rest.
Example: start [1, 3, 0, 5, 8, 5], end [2, 4, 6, 7, 9, 9] → 4.
int maxMeetings(const vector<int>& start, const vector<int>& end);
Input (start, end) | Output | Explanation |
|---|---|---|
([1, 3, 0, 5, 8, 5], [2, 4, 6, 7, 9, 9]) | 4 | (1,2), (3,4), (5,7), (8,9) |
([10, 12, 20], [20, 25, 30]) | 1 | 20 is not strictly after 20 |
([1, 2], [1, 2]) | 2 | Instant meetings |
([1, 1, 1], [2, 2, 2]) | 1 | All overlap |
([1], [5]) | 1 |
(Confirm: a meeting may start only when its start is strictly greater than the previous meeting's end.)
On Practick another engineer interviews you live for 60 minutes on a question from this bank. They have the full interviewer guide beside the call: the expected answer to every follow-up, hints to give if you stall, and a scoring rubric. You get the model solution once the session settles. It is free: interview someone for an hour and you have earned your own.
Book a free mock interviewAll 474 dsa interview questions
DSA mock interviews · System design interview questions · Free mock interview practice · Browse interviewers · Sign in