Skip to content
CampusEduX

Merge K Sorted Arrays

Mediumjavapythonccppjavascript

Given K sorted arrays, merge them into a single sorted array.

Input Format

The first line contains an integer K. Each of the next K lines describes one array: it starts with its length L, followed by L space-separated integers in non-decreasing order.

Output Format

Print all the values merged into one non-decreasing sequence, separated by single spaces.

Related Problems

  • Implement Min Heap
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Implement Max Heap
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • K Largest Elements
    Easy · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...