Amazon Coding Interview: Booking Window Consolidation
Based on questions reported for Amazon interviews
The interviewer opens
Hi, and thanks for joining. Welcome to your interview for the software engineer role at Amazon. We'll work through a coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause the interview any time with the Pause button at the top right of your screen.
The problem is about consolidating booked time ranges in a scheduling service, and it's up in the Problem tab now. Please read it through, take your time, and ask me any questions before you start.
The problem
A scheduling service stores booked time ranges and needs them consolidated into the fewest non-overlapping ranges.
intervals: a list of[start, end]pairs (start <= end), sorted by start. Ranges may overlap.
Return the merged list, sorted by start, where any ranges that overlap are combined into one. Two ranges that just touch (one ends exactly where the next starts) count as overlapping and are merged.
Example: intervals = [[1,3],[2,6],[8,10],[10,12],[15,18]] → [[1,6],[8,12],[15,18]]
Sizes: 0 <= len(intervals) <= 10^4.