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.
Input Format
Input is managed for you
Output Format
Output is managed for you
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.
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
5 2 C D +
Output
30