My-LeetCode-Solvings

C# Code Challenges Solved on LeetCode


Project maintained by F4NT0 Hosted on GitHub Pages — Theme by mattgraham

1614. Maximum Nesting Depth of the Parentheses

Level: Easy

Language: C#

Topic: String

Unit Tests: 1614 - Testing Results


A string is a valid parentheses string (denoted VPS) if it meets one of the following:

We can similarly define the nesting depth depth(S) of any VPS S as follows:

For example, "", "()()", and "()(()())" are VPS’s (with nesting depths 0, 1, and 2), and ")(" and "(()" are not VPS’s.

Given a VPS represented as string s, return the nesting depth of s.

Example 1:

Example 2:

Constraints: