Calculator Problem (Leetcode 227) & (Leetcode 150)

calculator会想到stack,不同题目的处理方式不一样
227 Basic Calculator II

class Solution {
public:
    int calculate(string s) {
        if(s.empty()) return 0;
        stack st;
        char sign = '+';
        int cur = 0;
        for(int i=0; i

Leetcode 150 Evaluate Reverse Polish Notation:

class Solution {
public:
    int evalRPN(vector& tokens) {
        if(tokens.empty()) return 0;
        stack st;
        for(int i=0; i

你可能感兴趣的:(Calculator Problem (Leetcode 227) & (Leetcode 150))