All practice tasks

Coding (Algo)

Merge Sorted Feeds

Heap · Medium

An offline reader loads several already-sorted event feeds. It needs one sorted timeline without re-sorting all events.

Merge all integer feeds while retaining duplicate timestamps.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ feeds:integer[][] }

Input rules

  • Each feed is sorted nondecreasing.

What each field means

  • feeds — integer arrays, each already sorted in nondecreasing order. Empty feeds are allowed.

Output

Return value and rules

  • Return one nondecreasing array containing every input element.
  • Preserve duplicate values, including duplicates from different feeds.
  • No elements across all feeds produce [].

Constraints

  • 0 <= feeds.length <= 200; at most 100000 elements across all feeds
  • Values in [-1000000000,1000000000]; empty feeds allowed.

Examples

Example 1

{
  "feeds": [
    [
      1,
      4
    ],
    [
      2,
      3
    ],
    [
      0,
      5
    ]
  ]
}

Returns

[
  0,
  1,
  2,
  3,
  4,
  5
]

Example 2

{
  "feeds": []
}

Returns

[]

Required complexity

O(N log(k+1)) time and O(k) auxiliary space excluding output

What this task practices

Merge Sorted Feeds is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.