Quant Memo
Coding/●●●●

Deepest nesting level of parentheses

A configuration language lets you nest guard conditions with ( and ). You already know the string is valid (every opener is matched). What you care about is readability: expressions nested too deep are hard to reason about, so you want to flag the maximum depth.

"()"            -> 1
"((()))"        -> 3
"(a(b)((c)))"   -> 3
""              -> 0

Return the maximum nesting depth of a valid parenthesis string. Aim for O(n)O(n).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions