FunctionRacerProblemsRace

Join Two Lists

EasyLinked listsPython, JavaScript, TypeScript, Java, C++

Return one list made of all the nodes of l1 followed by all the nodes of l2, each in its original order. Either list may be empty.

Linked lists appear in the tests as the list of their values, like [1,2,3]. Each node is a ListNode with .val and .next; the class is already defined for you.

Example 1

l1 [1,2]
l2 [3,4]
returns [1,2,3,4]

1, 2, 3, 4.

Example 2

l1 []
l2 [5]
returns [5]

The first list is empty.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Linked lists problems