Problem
You get the heads of two linked lists, a and b, each already sorted in ascending order. Splice them together into one sorted list and return its head. Reuse the existing nodes rather than making new ones.
Example 1
- Input
- a = 1
- Output
- 2 -> 4, b = 1 -> 3 -> 4 → 1 -> 1 -> 2 -> 3 -> 4 -> 4
Example 2
- Input
- a = (empty), b = 0
- Output
- 0
Example 3
- Input
- a = (empty), b = (empty)
- Output
- (empty)
If both are empty, return None (null in TypeScript).
Constraints
0 <= number of nodes in each list <= 50-100 <= Node.val <= 100Both lists are sorted in non-decreasing order.