Python interview question: merge two sorted linked lists

EasyLinked list

Problem

first and second are linked lists of order times (ListNode: val, next), each sorted ascending; examples show a list as its values. Merge them into one sorted list by relinking the existing nodes, without creating new ones, and return its head.

def merge_order_streams(first: ListNode | None, second: ListNode | None) -> ListNode | None:

Example

Solve it free

Checked against hidden tests, right in your browser. No sign-up needed.

Skills it tests

More interview questions

All questions