Leetcode:计算逆波兰式(后缀表达式)的值

题目描述

计算逆波兰式(后缀表达式)的值

运算符仅包含"+","-","*"和"/",被操作数可能是整数或其他表达式

例如:

  ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9↵  ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6

Java实现代码

import java.util.Stack;
public class Solution {
    public int evalRPN(String[] tokens) {
        Stack stack = new Stack();        
        for(int i = 0;i

 

你可能感兴趣的:(Leetcode:计算逆波兰式(后缀表达式)的值)