Running Union Length after Interval Uploads
Updated
Problem statement
Each row [left, right] uploads a continuous half-open interval [left, right) with left < right. Intervals may overlap or touch.
After every upload, return the total length covered by the union of all intervals seen so far.
Function
runningUnionLengths(uploads: long[][]) → long[]Examples
Example 1
uploads = [[1,5],[3,8]]return = [4,7]The second interval adds only its uncovered suffix.
Example 2
uploads = [[1,2],[5,9]]return = [1,5]Disjoint lengths add.
Constraints
1 <= uploads.length <= 2000-10^12 <= left < right <= 10^12
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Earliest Meeting Time for All EmployeesCapital One · OACapital One interview questions
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Largest Team Where Every Pair OverlapsWalmart · OAWalmart interview questions
- Minimum Cars for Rental RequestsGoogle · OA · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Minimum Meeting RoomsJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximum Compatible Time WindowsIBM · OAIBM interview questions
- Merge Overlapping IntervalsGoldman Sachs · OAGoldman Sachs interview questions
- Maximum Concurrent ProcessesMorgan Stanley · OA · ONSITE INTERVIEWMorgan Stanley interview questions
- Track Received Byte RangesRoblox · OARoblox interview questions
- Merge IntervalsBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions