Skip to content

Practice Maximum Nesting Depth of the Parentheses

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1614
LeetCode Problem

Maximum Nesting Depth of the Parentheses

Problem Statement

Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.

Source: Maximum Nesting Depth of the Parentheses on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "(1+(2*3)+((8)/4))+1"
Output
3

# Example 2

Input
s = "(1)+((2))+(((3)))"
Output
3

# Example 3

Input
s = "()(())((()()))"
Output
3

Constraints

1 <= s.length <= 100
s consists of digits 0-9 and characters '+', '-', '*', '/', '(', and ')'.
It is guaranteed that parentheses expression s is a VPS.

Related LeetCode Problems

Practice more problems similar to Maximum Nesting Depth of the Parentheses.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.