FastPrepMerge Two Descending Linked Lists
Problems/Merge Two Descending Linked Lists

Merge Two Descending Linked Lists

Microsoft logoMicrosoft● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft intern onsite interview. The report gives the goal of merging two descending lists. It leaves out empty input, repeated values, examples, the function signature and the limits. Our version is about 86% the same as the reported question.

Given the heads of two singly linked lists listA and listB, each sorted in nonincreasing order, merge their nodes into one linked list that is also sorted in nonincreasing order.

Preserve every node value, including duplicates. Either input list may be empty.

Function

mergeDescendingLists(listA: ListNode, listB: ListNode) → ListNode

Examples

Example 1

listA = [9,7,3]listB = [10,8,7,1]return = [10,9,8,7,7,3,1]
listA
973
listB
10871
return
10987731
From listAFrom listB

At each step, append the larger current head. Both nodes with value 7 remain in the merged list.

Example 2

listA = []listB = [5,5,2]return = [5,5,2]
listA
empty
listB
552
→
return
552

When one input is empty, the other list is already the complete descending result.

Example 3

listA = [4,2]listB = [3]return = [4,3,2]
listA
42
listB
3
return
432
From listAFrom listB

The head 4 is followed by 3, then the remaining node 2.

Constraints

  • The two lists contain at most 100000 nodes in total.
  • Every node value is a signed 32-bit integer.
  • Each input list is sorted in nonincreasing order.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
  • Merge Two Sorted Linked ListsZS · ONSITE INTERVIEWZS interview questions
  • Middle Node Of A Linked ListNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Build and Check a Palindrome Linked ListOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Reverse a Singly Linked ListGEP · ONSITE INTERVIEW
  • Merge Two Sorted Linked ListsApple · ONSITE INTERVIEWApple interview questions
  • Reverse Linked ListThe Walt Disney Company · OA · ONSITE INTERVIEWThe Walt Disney Company interview questions
  • Detect a Linked-List CycleGoogle · ONSITE INTERVIEWGoogle interview questions
  • Detect a Cycle in a Linked ListPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Reverse a Singly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions

Interview reports that mention this question

  • Microsoft CoreAI SWE Intern Loops: 4 Experiences (Part 2 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft 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 mergeDescendingLists(ListNode listA, ListNode listB) {
        // Write your code here.
    }

}
Checking account…