Maximum Nesting Depth of the Parentheses

Easy · Stack & Monotonic Stack · about 5 minutes

Asked at Meta, Amazon, Google, Intel, Bloomberg, SpaceX.

Given a valid parentheses expression s (which may contain digits and operators), return its maximum nesting depth of parentheses.