FunctionRacerProblemsRace

Maximum Nesting Depth of Parentheses

BeginnerStringsPython, JavaScript, TypeScript, Java, C++

s is a valid math expression with digits, operators and balanced parentheses. The depth at a point is the number of ( that are still open there. Return the largest depth reached anywhere in s.

Example 1

s "(1+(2*3)+((8)/4))+1"
returns 3

The 8 sits inside three open parentheses.

Example 2

s "1+2"
returns 0

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems