49fff18f创建于 2023年2月5日历史提交
public class Solution {
    public int CalPoints(string[] operations) {
        List<int> stack = new();

        foreach(var operation in operations)
        {
            switch(operation)
            {
                case "D":
                    stack.Add(stack[stack.Count()-1]*2);
                    break;
                case "+":
                    stack.Add(stack[stack.Count()-1] + stack[stack.Count()-2]);
                    break;
                case "C":
                    stack.RemoveAt(stack.Count()-1);
                    break;
                default:
                    stack.Add(int.Parse(operation));
                    break;
            }
        }
        
        return stack.Sum();
    }
}