Trains the technique from
LeetCode 2011Final Value of Variable After Performing OperationsThis 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 stock clerk carries a hand tally whose reading starts at 0. Every adjustment is written into a log as one of four three-character tokens naming the tally n:
"++n" and "n++" each raise the reading by one;"--n" and "n--" each lower it by one.Whether the clerk wrote the pair of signs before or after the letter makes no difference to what happens to the reading.
taps holds the log entries in the order they were made. Return the reading once every entry has been applied. The reading may end up negative.
Example 1
The reading starts at 0, drops to -1, then rises to 0 and to 1.
Example 2
All three entries lower the reading, so it runs 0, -1, -2, -3.
Example 3
A single rise takes the reading from 0 to 1.
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 counter_reading(taps: list[str]) -> int:public int counterReading(String[] taps)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.