Maximum Nesting Depth

L4 Easy Stack
Concept
The depth of a well-formed parentheses string equals the maximum number of open parentheses that are balanced at the same time.
Given a string s containing balanced round brackets () alongside other characters, return the maximum nesting depth of the parentheses. Unbalanced strings are not possible in the input.
Examples
▸ s = "(1+(2*3)+((8)/4))+1"
→ 3
▸ s = ""
→ 0
▸ s = "(a(b(c)))"
→ 3
Progressive Hints
Hint 1 · Nudge
Depth is a counter that climbs with '(' and drops with ')'. Ride it to its maximum.
Hint 2 · Plan
Loop over the string keeping a depth counter that goes up by 1 on '(' and down by 1 on ')'. Track the largest value the counter ever reaches and return it.
Hint 3 · Approach
depth = 0, best = 0. For each c in s: if c == '(' then depth = depth + 1 and best = the larger of best and depth; if c == ')' then depth = depth - 1. Return best.
Output
// Run your code to see the output here.