Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Merge two sorted linked lists

Hardware interview practice

Merge two sorted linked lists

EasyLinked ListsSystemVerilog

Merge two linked lists sorted by node value and return one sorted list.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
a = 1 -> 3 -> 5, b = 1 -> 2 -> 6
Expected output
1 -> 1 -> 2 -> 3 -> 5 -> 6

Taking from a when equal preserves stable ordering while reusing every input node.

What to cover

Requirements

  1. Reuse the existing nodes.
  2. Keep the merge stable when values are equal.
  3. Append the remaining tail after one input is exhausted.
Continue practicing

Related questions

Linked ListsReverse a singly linked list→Linked ListsDetect a linked-list cycle→Linked ListsFind the middle node→
asic.fyi · Learn silicon end to end.info@asic.fyi