class Solution { public int calPoints(String[] operations) { int[] a = new int[1000]; int j =0; int sum = 0; for(int i=0;i<operations.length;i++){ if("+".equals(operations[i])){ a[j] = a[j-1]+a[j-2]; j++; }else if("D".equals(operations[i])){ a[j] = 2*a[j-1]; j++; }else if("C".equals(operations[i])){ j-=1; }else{ a[j] = Integer.parseInt(operations[i]); j++; } } for(int k = 0;k<j;k++){ sum+=a[k]; } return sum; } }
标签:operations,int,sum,equals,else,LeetCode682,++ From: https://www.cnblogs.com/lvliyu/p/18329917