Problem
You get the head of a linked list and a number k. Split the list into exactly `k` consecutive parts and return them as an array of heads. The part sizes must be as equal as possible: no two parts differ in size by more than one, and earlier parts are never smaller than later ones. If there are fewer nodes than k, some parts are empty (None in Python, null in TypeScript).
Example 1
- Input
- 1
- Output
- 2 -> 3, k = 5 → [1], [2], [3],
- Why
- empty), (empty
Example 2
- Input
- 1
- Output
- 2 -> ... -> 10, k = 3 → [1, 2, 3, 4], [5, 6, 7], [8, 9, 10]
The tests show each part as a list of values, and an empty part as None / null.
Constraints
0 <= number of nodes <= 10000 <= Node.val <= 10001 <= k <= 50