Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 612 Bytes

File metadata and controls

16 lines (13 loc) · 612 Bytes

Problem 18: Arithmetic Expression Parser (Basic Calculator II)

Problem Statement

Given a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. You may assume that the given expression is always valid. All intermediate results will be in the range of [-2^31, 2^31 - 1]. Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

Input Format

  • A string s.

Example

Input: s = "3+2*2"
Output: 7 Input: s = " 3/2 "
Output: 1