Remove Interval
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A set of numbers is described by intervals, a list of half-open ranges [a, b) (containing every x with a <= x < b). The ranges are sorted by start and are strictly separated: each range ends before the next one begins (b_i < a_{i+1}).
Remove the half-open range toBeRemoved = [x, y) from the set and return what is left in the same format: sorted, non-empty half-open ranges. Return an empty list if nothing remains.
Examples
Constraints
- 1 <= intervals.length <= 10^4
- -10^9 <= a_i < b_i <= 10^9
- b_i < a_{i+1} for consecutive intervals
- toBeRemoved.length == 2 and x < y
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.