P16163 [GeeksforGeeks] Fun with expresions2523
普及
题目描述

Given a string s which represent an expression, evaluate this expression.
Integer division should truncate towards zero.

Example 1:
Input: s = "1020+10"
Output: 210
Example 2:
Input: s = "16
5-5/15"
Output: 80

Your Task:
You don't need to read or print anyhting. Your task is to complete the function calculate() which takes s as input parameter and returns the value of the expression.

Expected Time Compelxity: O(|s|)
Expected Space Complexity: O(1)

Constraints:
1 <= |s| <= 10^{5}
^{s is a valid expression.}
Note: The answer is guaranteed to fit in a 32-bit integer.

输入格式

见题面

输出格式

见题面

样例输入
s = "10*20+10"
样例输出
210