← 返回 meta 的题目列表Calculator: Evaluate Expression with '+' and '*' Only
类型:online_judge
Given an expression string s containing non-negative integers, +, *, and spaces only, evaluate it.
Rules:
* has higher precedence than +.
No parentheses.
The result fits in a signed 64-bit integer.
Implement the evaluator.
Constraints: |s| <= 2*10^5.
Examples:
"3+2*2" => 7
" 3 + 5 * 2 + 4" => 17
Example
Input
3+2*2
Output
7