Coding

Evaluate a mathematical expression given as a string.

Given a string representing a mathematical expression, evaluate it and return its value. The expression can contain basic arithmetic operators, and integer division should truncate toward zero.

Input: s = "3+5/2"

Output: 5

Explanation: Following the order of operations (PEMDAS), 5 / 2 = 2 (integer division), and 3 + 2 = 5.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions