Trains the technique from
LeetCode 416Partition Equal Subset SumThis 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 dispatcher has two identical trailers standing at a loading bay and an integer array weights, where weights[i] is the weight of the i-th crate.
Every crate has to be rolled onto exactly one of the two trailers, and no crate may be left on the bay or cut apart. The bay foreman wants the two trailers to leave carrying the same total weight.
Return true if such a hand-out exists and false if it does not. A trailer is allowed to end up with any number of crates, and the crates do not have to be handed out in the order they are listed.
Example 1
Rolling the 6 and the 4 onto one trailer leaves the 2 and the 8 for the other, and both leave with 10.
Example 2
The crates weigh 19 in total, an odd figure, so no hand-out can leave the two trailers level.
Example 3
The three crates of weight 3 go on one trailer and the 4 and the 5 go on the other, and each trailer leaves with 9.
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 can_split_crates(weights: list[int]) -> bool:public boolean canSplitCrates(int[] weights)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.