← 返回 meta 的题目列表Simple Arithmetic Parser with Constant Space
类型:online_judge
Description
Given a string representing a simple mathematical expression containing only addition (+) and multiplication (*) operators, write a function to evaluate the value of the expression.
The evaluation should be done using constant space complexity without using a stack.
Input
A string expr with a maximum length of 100, containing only digits and operators + and *.
Output
An integer representing the evaluated value.
Example
Input: "3+5*2"
Output: 13
Input: "2*3+4"
Output: 10
Constraints
The expression will not be empty.
There will be no spaces between '+' and '*' operators.
Example
Input
"3+5*2"