You are keeping the scores for a baseball game with strange rules. You begin with an empty record, and you are given a list of operations `operations` to apply, where `operations[i]` is one of:
- An integer `x` (as a string): record a new score of `x`.
- `"+"`: record a new score that is the sum of the previous two scores.
- `"D"`: record a new score that is double the previous score.
- `"C"`: invalidate the previous score, removing it from the record.
Return the sum of all the scores on the record after applying all the operations. All operations are guaranteed to be valid at the moment they are applied.
Explanation:The record is empty, so the total is 0.
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 "+" there will always be at least two previous scores on the record.
- For "C" and "D" there will always be at least one previous score on the record.