Problems on bracket sequences will outlive us all. Today's variation is about finding the depth.
Given: A string containing a valid mathematical expression (digits, operators, parentheses).
Task: Return an integer representing the maximum nesting depth of parentheses.
Examples:
solve('1 + 2')
# Result: 0
solve('(1) + ((2))')
# Result: 2 (maximum in the second part of the expression)
solve('(3 * n + 1) / 2')
# Result: 1Share your one-liners (and not only) in the comments 👇🏻
#algosobes
Comments
0No comments yet.