FastPrepMerge K Sorted Linked Lists Into One
Problems/Merge K Sorted Linked Lists Into One

Merge K Sorted Linked Lists Into One

Capital One logoCapital One● HardINTERNNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two Capital One reports from the fall of 2017 include a final-round question that combines several sorted linked lists into one sorted list. One is from an intern in Plano and one is from a new graduate in Richmond. The intern report says about ten minutes were given for it. The other describes the input as an array of list heads.

Here there are up to 300 lists and 3000 nodes in total. Any list may be empty, and repeated values are all kept. These are our choices.

Our version is about 95% the same as the reported questions.

lists holds the heads of k linked lists, and the values inside each list never decrease from front to back. Some lists, or the whole array, may be empty.

Relink all of their nodes into a single list whose values never decrease, keeping every repeated value, and return its head.

Function

mergeKLists(lists: ListNode[]) → ListNode

Examples

Example 1

lists = [[3,9],[-1,4,4,12],[7]]return = [-1,3,4,4,7,9,12]
return
-13447912

All seven values end up in one list in order: -1 from the second list, then 3, both 4s, 7, 9 and 12.

Example 2

lists = [[10],[1],[5]]return = [1,5,10]
return
1510

Each list holds one node. Joined in order they give 1, 5, 10, which is not the order the lists were given in.

Example 3

lists = [[-4,-4],[],[-4]]return = [-4,-4,-4]
return
-4-4-4

The empty list adds nothing. All three -4 nodes are kept.

Constraints

  • 0 <= lists.length <= 300
  • Each list has at most 300 nodes, and all lists together have at most 3000.
  • -10^4 <= Node.val <= 10^4, and within each list the values never decrease.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Reverse Nodes in K-GroupAmazon · ONSITE INTERVIEW
  • Merge K Sorted Linked ListsThe Walt Disney Company · OA · ONSITE INTERVIEWThe Walt Disney Company interview questions
  • Merge K Sorted ListsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Reverse Nodes in k-GroupMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Merge K Sorted ListsSkydio · ONSITE INTERVIEWSkydio interview questions
  • Reverse a Linked List in Groups of KExpedia · ONSITE INTERVIEWExpedia interview questions
  • Sorted Doubly Linked List to Balanced BST In PlaceSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Merge K Sorted Linked ListsBharatPe · PHONE SCREEN
  • Reverse Nodes in K-GroupByteDance · PHONE SCREENByteDance interview questions
  • Reverse a Linked ListCisco · PHONE SCREENCisco interview questions

Capital One interview experiences

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One 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…