leetle

Daily challenge for 2026-02-02

398. Stack Balanced Bracket Depth

Given a string s containing only parentheses '(', ')', '{', '}', '[' and ']', determine the maximum nesting depth of the validly matched brackets. If the string is not validly formed (e.g., unmatched brackets), return -1.

For example, in "{([])}", the depth is 3 (curly, then square, then round).

Input: s = "{([()])}"
Output: 4

Run this challenge interactively in Python or JavaScript when the app loads.