Resolve Overlapping Price Ranges
Updated
Problem statement
Each row of assignments sets a price on the half-open coordinate range [left,right). Apply the rows in input order. Return the final non-overlapping priced segments as [left,right,price], sorted by left endpoint.
For this exercise, assume a later assignment replaces every earlier price in its overlap. Leave uncovered gaps out of the result. Merge touching segments when their prices are equal. A zero price is still a covered price, not deletion. Empty input returns an empty array.
Function
resolvePriceRanges(assignments: int[][]) → int[][]Examples
Example 1
assignments = [[1,6,10],[3,5,20]]return = [[1,3,10],[3,5,20],[5,6,10]]The second update replaces the middle of the first range. The earlier price remains on [1,3) and [5,6).
Example 2
assignments = [[0,2,7],[2,4,7],[6,8,0]]return = [[0,4,7],[6,8,0]]The first two ranges touch at 2 and share price 7, so they merge. The uncovered gap [4,6) is omitted, while the zero-price range remains.
Example 3
assignments = [[0,5,4],[0,5,9]]return = [[0,5,9]]The later assignment covers the entire earlier interval, so only price 9 remains.
Constraints
0 <= assignments.length <= 1000.- Every assignment has exactly
3integers. -1000000 <= assignments[i][j] <= 1000000.- Each row is
[left,right,price]withleft < right, endpoint values in-1000000..1000000, and price in0..1000000.
More Squarepoint Capital interview questions
- Evaluating Circuit ExpressionsOA · Seen Jul 2026
- Match an XOR-Adjusted SumOA · Seen Oct 2025
- Maximize Palindromic WordsOA · Seen Oct 2025
- Minimize the Sum with Ceiling HalvesOA · Seen Oct 2025
- Longest Increasing Subsequence from Two ArraysOA · Seen Oct 2025
- Empty ShelfOA · Seen Sep 2024
- Suggested ProductsOA · Seen Sep 2024
- Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
- Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
- Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Newly Painted Length Per DayGoogle · ONSITE INTERVIEWGoogle interview questions
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Largest Team Where Every Pair OverlapsWalmart · OAWalmart interview questions
- Minimum Meeting RoomsJP Morgan Chase · OAJP Morgan Chase interview questions
- Maximum Compatible Time WindowsIBM · OAIBM interview questions
- Earliest Meeting Time for All EmployeesCapital One · OACapital One interview questions
- Total Server DowntimeVisa · OAVisa interview questions
- Merge Overlapping IntervalsGoldman Sachs · OAGoldman Sachs interview questions
- Track Received Byte RangesRoblox · OARoblox interview questions
- Merge IntervalsBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions