Baseball Game Problem

Baseball Game Problem — ExecCode Easy DSA Practice

Solve the Baseball Game problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a list of strings operations, where operations[i] is the i^th operation you must apply to the record and is one of the following:. Your task is to compute the required answer and return the sum of all the scores on the record after applying all the operations. You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record. - An integer x. Record a new score of x.

Examples

Input {"operations": ["5", "2", "C", "D", "+"]}; Output 30. Input {"operations": ["5", "-2", "4", "C", "D", "9", "+", "+"]}; Output 27

Constraints

1 <= operations.length <= 1000 operations[i] is "C", "D", "+", or a string representing an integer in the range [-3 10^4, 3 10^4]. For operation "+", there will always be at least two previous scores on the record. For operations "C" and "D", there will always be at least one previous score on the record.

Practice Baseball Game free on ExecCode. Browse DSA problems, topic map, and placement guides.