# stacks medium

The Scorekeeper's Eraser

This scorekeeper has special commands: erase cancels the last score, double scores twice the last score, combo scores the sum of the last two. 📝

You get tokens — a number, erase, double, or combo (commands always valid). Print the total of all surviving scores.

Example:

Input: tokens = ["5", "2", "combo", "double"] Output: 28

Scores stack up as 5, 2. combo adds 5 + 2 = 7 (stack: 5, 2, 7). double adds 2 × 7 = 14 (stack: 5, 2, 7, 14) — the total is 5 + 2 + 7 + 14 = 28.

💡 need a hint?

stk-scorekeepers-eraser.py🔒 given lines are locked — write your code in between
loading...