Reported September 2025
Microsoftlinked list

Merge Two Descending Linked Lists

Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Microsoft OA. Under 2s to a working solution.
Founder's read

Microsoft reported this one in September 2025, and the detail that matters is in the statement: both lists are already sorted in nonincreasing order, and duplicates must survive. That makes it a merge, not a sort. If you've got an OA coming, this is the friendly kind of question, a linked list merge with a flipped comparison. The danger isn't the idea. It's the pointer bookkeeping under a clock. StealthCoder sits invisibly on your screen as a safety net if you blank on the dummy node setup, but you can walk in knowing the whole script already.

The problem

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]
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]
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]
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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is the merge step from merge sort, run on linked lists. Make a dummy head and a tail pointer. Compare the current heads of listA and listB. Attach the larger one to tail, advance that list, advance tail. When one list runs out, attach the other whole, since it's already descending. Return dummy.next. Ties are fine: with equal values, take either one, and both 7s in Example 1 survive because you never skip a node. The common pitfalls are flipping the comparison the wrong way and ascending by habit, forgetting to handle an empty list, and creating new nodes instead of relinking. With up to 100000 nodes total, recursion risks stack depth, so go iterative. That's O(n+m) time and O(1) extra space. If your mind goes blank mid-assessment, StealthCoder is the hedge that hands you the pointer logic live.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Merge Two Descending Linked Lists cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as merge two sorted lists. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Microsoft's OA.

Microsoft reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Merge Two Descending Linked Lists FAQ

How hard is Merge Two Descending Linked Lists really?+

Easy. It's the classic merge two sorted lists problem with the order reversed. If you've written a dummy-node merge once, you can write this in a few minutes. The only real risk is a sloppy comparison or a missed empty-list case.

What's the trick to getting it right?+

Use a dummy head and a tail pointer. At each step, attach whichever current node has the larger value, then advance. When one list ends, link the remainder of the other directly. Return dummy.next. No sorting needed since both inputs are already ordered.

Should I use recursion or iteration?+

Iteration. The total can reach 100000 nodes, and a recursive merge goes one frame deep per node, which can overflow the stack in some languages. The iterative version is just as short and uses constant extra space.

How do I handle duplicates and empty lists?+

Duplicates need no special code. When values are equal, take either node and both end up in the result. For empty lists, the loop never runs and you attach the non-empty remainder, so an empty listA just returns listB. Both empty returns null.

How do I prepare for this in 48 hours?+

Write the dummy-node merge from scratch twice, once ascending and once descending. Then test it on the three examples plus both-empty. Also revisit related linked list basics like reversing and finding the middle, since OAs often pair them.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Microsoft.

OA at Microsoft?
Invisible during screen share
Get it