Gamified challenge · Linked lists
Each parade is a singly linked list of floats (ListNodes with a number val), sorted from smallest to largest; equal numbers may appear. You get the head floats a and b (either may be null).
Write merge(a, b) that returns the head of one parade containing every float from both, still sorted. Reuse the floats you were given by relinking next; don't create new ones.
For 1 → 2 → 4 and 1 → 3 → 4 return 1 → 1 → 2 → 3 → 4 → 4. If one parade is empty, the answer is the other one.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google