Maximum Nesting Depth of Parentheses

A valid parentheses string (VPS) may contain digits 0-9, the operators + - * /, and the brackets ( and ). It is defined as: - "" (the empty string), or any…

A **valid parentheses string** (VPS) may contain digits `0-9`, the operators `+ - * /`, and the brackets `(` and `)`. It is defined as: - `""` (the empty string), or any single allowed non-parenthesis character, or - `AB`, where both `A` and `B` are VPS, or - `(A)` where `A` is a VPS. The **nesting depth** of a VPS is the maximum number of brackets that are open at any single point while scanning the string from left to right. Given a valid parentheses string `s`, return its maximum nesting depth. Indexing is **0-based**. **Example:** in `"(1+(2*3)+((8)/4))+1"`, the digit `8` is enclosed by three open brackets — the deepest point — so the maximum nesting depth is `3`.

- `1 <= s.length <= 100` - `s` consists of digits `0-9` and the characters `+`, `-`, `*`, `/`, `(`, `)`. - `s` is a valid parentheses string.

Example 1: input s = "(1+(2*3)+((8)/4))+1"; output 3. The "8" sits inside three open brackets — the deepest point — so the answer is 3.

Example 2: input s = "(1)+((2))+(((3)))"; output 3. The deepest single group "(((3)))" nests three brackets; separate groups are not summed.

Example 3: input s = "1+(2*3)/(2-1)"; output 1. No brackets are ever nested — at most one is open at a time, so the answer is 1.

Category: Strings. Topic: strings. Difficulty: Easy. Patterns: string-processing.