Maximum Nesting Depth of Parentheses
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
1 <= len(s) <= 100- The parentheses in
sare balanced
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Mirror CipherBeginner
- One Segment of OnesBeginner
- Percentage of Letter in StringBeginner
- Prefix of Any Word in a SentenceBeginner
- Remove Vowels from a StringBeginner
- Reverse Each WordBeginner
- Reverse Prefix of WordBeginner
- Reverse StringBeginner