Playing the Game

easy
1. You are playing a game.
 2. A String array is given to you whose ith string can be used to calculate points scored in the ith round
 3. If the string Si is
 an integer : it means the points scored in this round
 '+' 	    : it means the points scored in this round is the sum of the valid points in the previous two rounds
 'D'     : it means the points scored in this round is double the valid points scored in the previous  round
 'C'     : makes the points scored in the pervious round as invalid and that score must be removed
 4. You have to return the total points scored after completion of all the rounds.

Input Format

A String array(Each string in the array can have an integer, '+' character, 'D' character, 'C' character)

Output Format

An integer(representing the total score)

Constraints

The size of the input list will be between 1 and 1000.
 Every integer represented in the list will be between -30000 and 30000

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
8
5
-2
4
C
D
9
+
+
Output
27
Previous
Print Binary Numbers
Next
Cloning Linked List With Random Pointers And Next

Related Questions