Trains the technique from
LeetCode 1563Stone Game VThis 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 row of crates stands on a dock. weight[i] is the weight of the crate in position i, counting from the left end of the row.
While the row holds more than one crate, you do this:
The work finishes when one crate is left. Return the greatest number of points you can bank.
Example 1
Cut after the first crate. The left part weighs 3 and the right part weighs 3, so the choice is yours: crane off the left part, bank 3, and the row becomes [1, 2]. Cut that in the middle; the right part weighs 2 and goes, so bank 1 and one crate is left. That run banks 4.
Example 2
The row admits one cut, giving parts of weight 6 and 9. The heavier part is craned off, so 6 is banked and a single crate is left.
Example 3
Cut in the middle: both parts weigh 10, so crane one off and bank 10, leaving a row of two crates. Cut that in the middle too: both parts weigh 5, so bank 5 and one crate is left. That run banks 15.
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 best_banked_weight(weight: list[int]) -> int:public int bestBankedWeight(int[] weight)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.