https://leetcode.com/problems/evaluate-reverse-polish-notation/description/
// 숫자가 들어오면 push
// 연산 기호가 들어오면 두 개를 pop해서 연산 한 다음 결과값을 push
class Solution {
public int evalRPN(String[] tokens) {
Stack<Integer> stack = new Stack();
for (String s : tokens) {
if (s.equals("+") || s.equals("-") || s.equals("*") || s.equals("/")) {
int n1 = stack.pop();
int n2 = stack.pop();
int result = 0;
if (s.equals("+")) result = n2 + n1;
else if (s.equals("-")) result = n2 - n1;
else if (s.equals("*")) result = n2 * n1;
else result = n2 / n1;
stack.push(result);
} else stack.push(Integer.parseInt(s));
}
return stack.peek();
}
}