Streaming Interval Peak Concurrency
Updated
Problem statement
Meeting intervals arrive one at a time in the given order. After every insertion, return the highest concurrency observed anywhere in the timeline so far.
- Intervals are half-open:
[start, end). - An interval ending at time
tdoes not overlap one starting att. - The intervals are not sorted in advance.
Return one integer per arrival.
Function
peakConcurrencyAfterEachInsert(intervals: int[][]) → int[]Examples
Example 1
intervals = [[1,5],[2,4],[5,7],[3,6]]return = [1,2,2,3]The fourth insertion makes three intervals overlap during [3,4). The endpoint at 5 is handled as an end before a start.
Example 2
intervals = [[10,20],[0,10],[20,30]]return = [1,1,1]The three intervals only touch at endpoints, so the peak remains one.
Constraints
intervalsis non-empty.- Every row is
[start, end]withstart < end. - Coordinates are signed integers.
More Uber Onsite Interview questions
- Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Online Meeting Scheduler with Fixed RoomsONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Serialize and Deserialize an N-Ary TreeONSITE INTERVIEW · Seen Oct 2026
- Longest Continuous Subarray Within an Absolute-Difference LimitONSITE INTERVIEW · Seen Oct 2026
- K Smallest Squares from a Sorted ArrayONSITE INTERVIEW · Seen Sep 2026
- Grid Robot Route with Charging PrioritiesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Shortest Increasing Path to a TargetONSITE INTERVIEW · Seen Sep 2026
- My Calendar IONSITE INTERVIEW · Seen Sep 2026
- Per-Element Hit CounterONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Range ModuleWalmart · PHONE SCREENWalmart interview questions
- Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
- Intervals with Exactly One Person OnlineGoogle · ONSITE INTERVIEWGoogle interview questions
- Babysitter Quote with Hourly RatesUpstart · ONSITE INTERVIEWUpstart interview questions
- Delivery Cost TrackerRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- First-Fit Arena AllocatorAMD · PHONE SCREEN · ONSITE INTERVIEWAMD interview questions
- Cipher Cover Interval EditingDatabricks · ONSITE INTERVIEWDatabricks interview questions
- Calendar Event System with Pagination and IntersectionLead Bank · ONSITE INTERVIEWLead Bank interview questions
- Perfect AND Tree Leaf UpdatesPure Storage · ONSITE INTERVIEWPure Storage interview questions
- Deployment Window SchedulerStripe · OAStripe interview questions