Trains the technique from
LeetCode 1290Convert Binary Number in a Linked List to IntegerThis 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 tally machine punches cards and clips them one behind another. Every card carries a single hole state, either 0 or 1, plus a clip fastened to the card behind it, and the card at the end has an empty clip. Nothing in the machine records how many cards a chain holds.
Because the harness passes plain JSON, the chain reaches you as punches, listing the hole states in clip order starting at the front card. There is always at least one card.
Read the chain as a number written in base two, with the front card carrying the largest place value and the card at the end carrying the ones. Return that number.
Example 1
The front card is worth four, the middle one two, and the card at the end nothing, so the chain reads six.
Example 2
Only the front card and the card at the end are punched, worth eight and one, which adds to nine.
Example 3
The leading unpunched cards carry no weight, so only the ones place counts.
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 get_decimal_value(punches: list[int]) -> int:public int getDecimalValue(int[] punches)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.