PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Citadel

Merge K timestamped lists with timestamp coalescing

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic skills in merging multiple sorted sequences, coalescing records by key (timestamp), merging sorted value arrays, and analyzing time and space complexity.

  • medium
  • Citadel
  • Coding & Algorithms
  • Software Engineer

Merge K timestamped lists with timestamp coalescing

Company: Citadel

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given **k** sorted lists (or linked lists) of records. Each record has: - `timestamp` (integer) - `values` (an array of integers sorted in non-decreasing order) Each individual list is sorted by `timestamp` in non-decreasing order. Your task is to merge the k lists into **one** sorted list by `timestamp`, with the following special rule: - If multiple input records (possibly from different lists) have the **same `timestamp`**, you must **coalesce** them into a **single output record** with that timestamp. - The `values` array of the coalesced record is the **sorted merge** of all `values` arrays from records with that timestamp. Return the merged list of records sorted by `timestamp`. ### Input - `lists`: an array of length `k`, where each element is a list of records `(timestamp, values)` sorted by `timestamp`. ### Output - A single list of records `(timestamp, values)` sorted by `timestamp`, where each timestamp appears at most once. ### Constraints (you may assume) - `0 <= k <= 10^4` - Total number of records across all lists: `N` (up to ~10^5) - Total number of integers across all `values` arrays: `M` (up to ~10^5) - Timestamps fit in 32-bit signed integer. ### Example Input: - L1: `(1,[1,4]) -> (3,[2])` - L2: `(1,[0,5]) -> (2,[7])` - L3: `(3,[3,3])` Output: - `(1,[0,1,4,5]) -> (2,[7]) -> (3,[2,3,3])` (Notice timestamps `1` and `3` are merged first across lists, and their `values` arrays are merged into one sorted array.)

Quick Answer: This question evaluates algorithmic skills in merging multiple sorted sequences, coalescing records by key (timestamp), merging sorted value arrays, and analyzing time and space complexity.

Related Interview Questions

  • Implement a single-producer multi-consumer ring buffer - Citadel (medium)
  • Sort a Nearly Sorted Array - Citadel (hard)
  • Compute BBO and NBBO from order data - Citadel (medium)
  • Design dynamic weighted random sampling with updates - Citadel (medium)
  • Compute maximum later-earlier difference - Citadel (medium)
Citadel logo
Citadel
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
15
0
Loading...

You are given k sorted lists (or linked lists) of records. Each record has:

  • timestamp (integer)
  • values (an array of integers sorted in non-decreasing order)

Each individual list is sorted by timestamp in non-decreasing order.

Your task is to merge the k lists into one sorted list by timestamp, with the following special rule:

  • If multiple input records (possibly from different lists) have the same timestamp , you must coalesce them into a single output record with that timestamp.
  • The values array of the coalesced record is the sorted merge of all values arrays from records with that timestamp.

Return the merged list of records sorted by timestamp.

Input

  • lists : an array of length k , where each element is a list of records (timestamp, values) sorted by timestamp .

Output

  • A single list of records (timestamp, values) sorted by timestamp , where each timestamp appears at most once.

Constraints (you may assume)

  • 0 <= k <= 10^4
  • Total number of records across all lists: N (up to ~10^5)
  • Total number of integers across all values arrays: M (up to ~10^5)
  • Timestamps fit in 32-bit signed integer.

Example

Input:

  • L1: (1,[1,4]) -> (3,[2])
  • L2: (1,[0,5]) -> (2,[7])
  • L3: (3,[3,3])

Output:

  • (1,[0,1,4,5]) -> (2,[7]) -> (3,[2,3,3])

(Notice timestamps 1 and 3 are merged first across lists, and their values arrays are merged into one sorted array.)

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Citadel•More Software Engineer•Citadel Software Engineer•Citadel Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.