Trains the technique from
LeetCode 682Baseball GameThis 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 scorer's sheet reads entries, worked through in order. Each entry is one of the following:
"+": record a score equal to the last two recorded scores added together;"D": record a score equal to twice the last recorded score;"C": strike out the last recorded score, as though it had never been recorded.Return all the recorded scores added together once the whole sheet has been worked through.
Every "+" has at least two scores already recorded, and every "D" and "C" at least one.
Example 1
Three is recorded, then twice it, six, then twice that, twelve. Three, six and twelve add to twenty-one.
Example 2
Minus five is recorded, then twice it, minus ten, then those two added, minus fifteen. The three together come to minus thirty.
Example 3
One entry and one recorded score, so the total is that score.
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 cal_points(entries: list[str]) -> int:public int calPoints(String[] entries)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.