Merge Timestamped Record Lists
Updated
Problem statement
You are given several record lists. Each record has an integer timestamp and a string payload. The records in each list are already sorted from the smallest timestamp to the largest. Merge all records into one ordered list without dropping or changing any payload.
Here the input is two matching arrays: timestamps[i][j] is the timestamp of record j in list i, and payloads[i][j] is that record's payload. The two arrays have identical row lengths.
- Order records by timestamp ascending.
- For equal timestamps, records from a smaller input-list index come first.
- Within one list, equal-timestamp records keep their original order.
- Keep every record, including records with identical timestamps or payloads. Do not use payload contents to sort records.
Return a String[][] array. Each output row is [timestampText, payload], where timestampText is the timestamp written in base 10 with no leading zeroes. Return an empty array when there are no records. The inputs need not be modified.
Function
mergeTimestampedRecords(timestamps: int[][], payloads: String[][]) → String[][]Examples
Example 1
timestamps = [[1,4],[2,3]]payloads = [["a","d"],["b","c"]]return = [["1","a"],["2","b"],["3","c"],["4","d"]]The timestamp order interleaves the two input lists. Each payload stays attached to its timestamp.
Example 2
timestamps = [[5,5],[5],[]]payloads = [["left0","left1"],["right0"],[]]return = [["5","left0"],["5","left1"],["5","right0"]]At timestamp 5, list 0 precedes list 1, and its two records retain their original order. The empty list contributes nothing.
Example 3
timestamps = []payloads = []return = []No input lists means no records to return.
Constraints
0 <= timestamps.length = payloads.length <= 500.- For every list
i,timestamps[i].length = payloads[i].length. - The total number of records across all lists is at most
2000. Lists may be empty. -10^9 <= timestamps[i][j] <= 10^9; each timestamp row is nondecreasing.- Each payload contains from
0through40printable ASCII characters. Spaces, punctuation and empty payloads are valid.
More Nuro interview questions
- Fixed Window Average and ModePHONE SCREEN · Seen Dec 2026
- Assign Robots to Their Nearest Available ItemsPHONE SCREEN · Seen Oct 2026
- Container With Most WaterPHONE SCREEN · Seen Oct 2026
- Course Ordering with Concurrent UpdatesPHONE SCREEN · Seen Sep 2026
- Group Sparse Points by Distance ThresholdPHONE SCREEN · Seen Sep 2026
- Reveal a Minesweeper RegionPHONE SCREEN · Seen Aug 2026
- Schedule Buffered Video PlaybackPHONE SCREEN · Seen Aug 2026
- Maximum Value for Two Delivery RobotsPHONE SCREEN · Seen Jul 2026
- Thread-Safe Task Storage and Worker DispatchONSITE INTERVIEW · Seen Sep 2026
- Trapping Rain WaterONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Merge K Sorted Linked ListsBharatPe · PHONE SCREEN
- Top Ten Largest FilesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Merge Price-Delta FeedsCitadel · PHONE SCREENCitadel interview questions
- Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Streaming Median of Trade PricesXantium · PHONE SCREEN
- Top K Pins with Insert and QueryPinterest · PHONE SCREENPinterest interview questions
- Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN