Daily challenge for 2026-01-07
372. Stack Based Bracket Depth Sum
Given a string s consisting only of parentheses '(', ')', '{', '}', '[' and ']', determine the maximum nesting depth of validly matched brackets. The depth of an empty string is 0. The depth of a string containing only non-bracket characters is 0. The depth of a string like (A) or [A] or {A} is $1 + \text{depth}(A)$, where A is the content inside the brackets. The depth of a concatenation $AB$ is $\max(\text{depth}(A), \text{depth}(B))$. You must use a stack-like approach to track the current depth.
Example 1:
Input: s = "{([])}"
Output: 3 (Depth of () is 1, depth of [] is 2, depth of {} is 3)
Example 2:
Input: s = "()[]{}"
Output: 1
Example 3:
Input: s = "((()))"
Output: 3
Run this challenge interactively in Python or JavaScript when the app loads.