FastPrepMerge k Sorted Lists
Problems/Merge k Sorted Lists

Merge k Sorted Lists

Oracle logoOracle● HardFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: ( ദ്ദി ˙ᗜ˙ ) Big thanks to the friend who shared this valuable interview report! The candidate was asked to merge k sorted linked lists and build the linked-list structure from scratch. Shared on July 21, 2026. (ㅅ´ ˘ `)

You are given an array lists containing k linked-list heads. Every linked list is sorted in ascending order.

Merge all of the linked lists into one ascending linked list and return its head.

Function

mergeKLists(lists: ListNode[]) → ListNode

Examples

Example 1

lists = [[1,4,5],[1,3,4],[2,6]]return = [1,1,2,3,4,4,5,6]
return
11234456

The linked lists are:

1 -> 4 -> 5
1 -> 3 -> 4
2 -> 6

Merging them produces the sorted linked list 1 -> 1 -> 2 -> 3 -> 4 -> 4 -> 5 -> 6.

Example 2

lists = []return = []
return
empty

Example 3

lists = [[]]return = []
return
empty

Constraints

  • k == lists.length
  • 0 <= k <= 10^4
  • 0 <= lists[i].length <= 500
  • -10^4 <= lists[i][j] <= 10^4
  • Each lists[i] is sorted in ascending order.
  • The sum of all lists[i].length values does not exceed 10^4.

More Oracle Phone Screen questions

  • Remove Parentheses from a Plus-Minus ExpressionPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Oct 2026
  • Shortest Window by Distinct-Value SumPHONE SCREEN · Seen Oct 2026
  • Detect a Cycle in a Directed GraphPHONE SCREEN · Seen Oct 2026
  • Time-Based Key-Value StorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Remove Adjacent Duplicates in String IIPHONE SCREEN · Seen Oct 2026
  • Sum Root-to-Leaf Binary NumbersPHONE SCREEN · Seen Oct 2026
  • Longest All-Present Attendance StreakPHONE SCREEN · Seen Oct 2026
  • Next PermutationPHONE SCREEN · Seen Sep 2026
  • Valid ParenthesesPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Merge k Sorted ListsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Greedy Person-Cake Matching DistanceSnowflake · PHONE SCREENSnowflake interview questions
  • LRU Cache with Expiring EntriesPaytm · PHONE SCREENPaytm interview questions
  • Merge K Sorted Linked ListsBharatPe · PHONE SCREEN
  • Merge K Sorted ListsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
  • Merge Timestamped Record ListsNuro · PHONE SCREENNuro interview questions
  • LRU Cache with TTLPatreon · PHONE SCREEN · ONSITE INTERVIEWPatreon interview questions
  • LRU Cache with TTLAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Merge k Sorted ListsZS · ONSITE INTERVIEWZS interview questions

Oracle interview experiences

  • Oracle SWE Onsite Interview Experience: 1 Experience
All Oracle interview questionsSee Oracle hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode mergeKLists(ListNode[] lists) {
        // write your code here
    }

}
Checking account…