Trains the technique from
LeetCode 110Balanced Binary TreeThis 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 rigging crew stacks a scaffold from steel joints. One joint sits on the pad, and every joint can carry up to two joints above it: one clamped to its left brace and one clamped to its right brace. Each joint is stamped with a load rating, which runs negative for joints rated in tension.
Because the harness passes plain JSON, the scaffold arrives as the array struts, listed level by level from the pad joint upwards. The first entry is the pad joint's rating, then entries come in pairs giving the left-brace and right-brace joints of the next joint in that same level order. A brace carrying nothing is written null, and a null contributes no pair of its own. An empty array means the crew put up no scaffold at all.
Call the lift of a joint the number of levels in the stack resting on it, counting the joint itself, and the lift of an empty brace zero. The site inspector signs off a scaffold as steady when at every single joint the lift on its left brace and the lift on its right brace are within one of each other. A scaffold that was never put up passes by default.
Return true when the inspector signs off and false when some joint fails the rule.
Example 1
Both braces of the pad joint carry two levels, and joints 3 and 9 each carry one level on one brace and nothing on the other, which is within the allowance.
Example 2
Joint 8 carries three levels on its left brace and nothing on its right, so the lifts differ by three.
Example 3
The pad joint looks fine with three levels over each brace, but joint 2 carries two levels on its left brace and nothing on its right, so the failure sits above the pad.
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 scaffold_stands_steady(struts: list) -> bool:public boolean scaffoldStandsSteady(Integer[] struts)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.