Trains the technique from
LeetCode 494Target 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 station keeper has a queue of thruster burns already scheduled for the next pass. Burn i will move the station along its track by burns[i] units of drift, and before the pass starts the crew has to point each burn one way or the other: pointed ahead it adds that many units of drift, pointed astern it takes the same amount away. Every burn in the queue fires, in the order given, and none can be cancelled.
A plan is one choice of direction per burn. Two plans count as different as soon as a single burn points the other way, even when both plans finish on the same drift, and even when the burn measures 0 units and so pushes the station nowhere.
Return how many plans finish the pass with a drift of exactly net_shift units.
Example 1
Four burns ahead and one astern land on 8 - 2 = 6, and any one of the five burns can be the one pointed astern, so there are five plans.
Example 2
The 5 must point ahead, while the 0 still has two directions to be recorded in, so both plans count.
Example 3
Only pointing the 3 ahead and the 5 astern reaches -2, so a single plan works.
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 burn_plan_count(burns: list[int], net_shift: int) -> int:public int burnPlanCount(int[] burns, int netShift)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.