LeetCode 1614, Easy. Topics: String, Stack, Bracket Sequences. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 24 parametrized pytest cases, and a playground notebook:
Problem
Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.
Examples
Constraints
1 <= s.length <= 100
s consists of digits 0-9 and characters '+', '-', '*', '/', '(', and ')'.
- It is guaranteed that parentheses expression
s is a VPS.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026