Trains the technique from
LeetCode 725Split Linked List in PartsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A conveyor is built from cars clipped one behind another. Each car carries a load and a clip fastened to the car behind it, and the car at the end has an empty clip. Nothing on the conveyor records how many cars it holds.
Because the harness passes plain JSON, the conveyor reaches you as chain, listing the loads in clip order starting at the front car. An empty list means there are no cars at all.
Divide the conveyor into k parts, keeping the cars in their order, so that no two parts differ in length by more than one car and no earlier part is shorter than a later one. Parts may come out empty.
Return the k parts in order, each as its own list of loads.
Example 1
Three cars into five parts gives a base length of nothing and a remainder of three, so the first three parts take one car each and the last two come out empty.
Example 2
Ten cars into three parts gives a base length of three and a remainder of one, so the first part takes four cars and the other two take three.
Example 3
Two cars split evenly, one to each part.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def split_list_to_parts(chain: list[int], k: int) -> list[list[int]]:public List<List<Integer>> splitListToParts(int[] chain, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.