Merge K Sorted Sequences
Updated
Problem statement
Merge k sorted integer sequences into one nondecreasing array. Keep every occurrence, including duplicates. Empty sequences are allowed.
Use at most O(k) auxiliary space, excluding the input and returned array. Do not flatten and sort the input or repeatedly merge pairs of sequences.
Function
mergeSortedSequences(sequences: int[][]) → int[]Examples
Example 1
sequences = [[1,4,5],[1,3,4],[2,6]]return = [1,1,2,3,4,4,5,6]Each sequence contributes its smallest remaining value. The result is [1,1,2,3,4,4,5,6].
Example 2
sequences = [[],[-2,-2,7],[]]return = [-2,-2,7]Empty sequences contribute nothing. Both copies of -2 remain in the result.
Constraints
- 0 <= sequences.length <= 1000
- Each sequence is sorted in nondecreasing order.
- The total number of elements is at most 100000.
- -1000000 <= each element <= 1000000
- Use O(k) auxiliary space, excluding the input and returned array, where k is sequences.length.
More Citadel Phone Screen questions
- Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
- Square Root FunctionPHONE SCREEN · Seen Oct 2026
- Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
- Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
- Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
- Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026
- Top Ten Trades by Notional ValuePHONE SCREEN · Seen Sep 2026
- Exchange BBO and Market-Wide NBBOPHONE SCREEN · Seen Sep 2026
- Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN
- Defer Expenses to Preserve BalanceDRW · PHONE SCREENDRW interview questions
- Select the Top User MatchesDuolingo · PHONE SCREENDuolingo interview questions
- Meeting Rooms IIQuince · PHONE SCREENQuince interview questions
- Kth Largest Element in an ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
- Meeting Rooms IISecuronix · PHONE SCREEN
- Minimize Array Sum After K Halving OperationsDocuSign · PHONE SCREENDocuSign interview questions