Tap here to switch tabs
Problem
Submissions

Problem: Basic Calculator III

Basic Calculator III asks you to evaluate a valid arithmetic expression with parentheses and addition, subtraction, multiplication, and division, returning an integer with division truncated toward zero.

Statement

Given a string s representing a mathematical expression, evaluate and return its result as an integer.

The expression string contains digits, addition '+', subtraction '-', multiplication '*', division '/', and parentheses '(' and ')'.

Note: The integer division should truncate toward 00.

Constraints:

  • 1≤1 \leq s.length ≤104\leq 10^4

  • s consists of digits, '+', '-', '*', '/', '(', and ')'.

  • s is a valid expression.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Basic Calculator III

Basic Calculator III asks you to evaluate a valid arithmetic expression with parentheses and addition, subtraction, multiplication, and division, returning an integer with division truncated toward zero.

Statement

Given a string s representing a mathematical expression, evaluate and return its result as an integer.

The expression string contains digits, addition '+', subtraction '-', multiplication '*', division '/', and parentheses '(' and ')'.

Note: The integer division should truncate toward 00.

Constraints:

  • 1≤1 \leq s.length ≤104\leq 10^4

  • s consists of digits, '+', '-', '*', '/', '(', and ')'.

  • s is a valid expression.