pytudes._2021.leetcode.hard._224_basic_calculator
https://leetcode.com/problems/basic-calculator/
- Constraints:
1 ≤ s.length ≤ 3 * 10^5
s consists of digits, ‘+’, ‘-’, ‘(’, ‘)’, and ‘ ‘
s represents a valid expression
- Examples:
>>> Solution().calculate("0") 0
Module Contents
Classes
Functions
|
Return the evaluation of the given infix arithmetic expression |
- pytudes._2021.leetcode.hard._224_basic_calculator.calculate_via_rpn(expression)[source]
Return the evaluation of the given infix arithmetic expression
- Args:
expression: A valid infix arithmetic expression containing only numbers from R and symbols in ‘+’, ‘-’, ‘(’, ‘)’, and ‘ ‘
- Examples:
>>> calculate_via_rpn("1 + 1") 2 >>> calculate_via_rpn(" 2-1 + 2 ") 3 >>> calculate_via_rpn("(1+(4+5+2)-3)+(6+8)") 23
- See Also: