Baseball Game
easy
You have to keep score for a baseball game with strange rules. You are provided an array of string showing operation u have to do. Operation consists of :- 1. An integer x - Record a new score of x. 2. '+' - Record a new score that is the sum of the previous two scores. 3. 'D' - Record a new score that is double the previous score. 4. 'C' - Invalidate the previous score, removing it from the record.
Constraints
1. 1 <= ops.length <= 1000 2. For operation "+", there will always be at least two previous scores on the record. 3. For operations "C" and "D", there will always be at least one previous score on the record.
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
5 2 C D +
Sample Output
30