|
| 1 | +<h2><a href="https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses">Maximum Nesting Depth of the Parentheses</a></h2> <img src='https://img.shields.io/badge/Difficulty-Easy-brightgreen' alt='Difficulty: Easy' /><hr><p>Given a <strong>valid parentheses string</strong> <code>s</code>, return the <strong>nesting depth</strong> of<em> </em><code>s</code>. The nesting depth is the <strong>maximum</strong> number of nested parentheses.</p> |
| 2 | + |
| 3 | +<p> </p> |
| 4 | +<p><strong class="example">Example 1:</strong></p> |
| 5 | + |
| 6 | +<div class="example-block"> |
| 7 | +<p><strong>Input:</strong> <span class="example-io">s = "(1+(2*3)+((8)/4))+1"</span></p> |
| 8 | + |
| 9 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 10 | + |
| 11 | +<p><strong>Explanation:</strong></p> |
| 12 | + |
| 13 | +<p>Digit 8 is inside of 3 nested parentheses in the string.</p> |
| 14 | +</div> |
| 15 | + |
| 16 | +<p><strong class="example">Example 2:</strong></p> |
| 17 | + |
| 18 | +<div class="example-block"> |
| 19 | +<p><strong>Input:</strong> <span class="example-io">s = "(1)+((2))+(((3)))"</span></p> |
| 20 | + |
| 21 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 22 | + |
| 23 | +<p><strong>Explanation:</strong></p> |
| 24 | + |
| 25 | +<p>Digit 3 is inside of 3 nested parentheses in the string.</p> |
| 26 | +</div> |
| 27 | + |
| 28 | +<p><strong class="example">Example 3:</strong></p> |
| 29 | + |
| 30 | +<div class="example-block"> |
| 31 | +<p><strong>Input:</strong> <span class="example-io">s = "()(())((()()))"</span></p> |
| 32 | + |
| 33 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 34 | +</div> |
| 35 | + |
| 36 | +<p> </p> |
| 37 | +<p><strong>Constraints:</strong></p> |
| 38 | + |
| 39 | +<ul> |
| 40 | + <li><code>1 <= s.length <= 100</code></li> |
| 41 | + <li><code>s</code> consists of digits <code>0-9</code> and characters <code>'+'</code>, <code>'-'</code>, <code>'*'</code>, <code>'/'</code>, <code>'('</code>, and <code>')'</code>.</li> |
| 42 | + <li>It is guaranteed that parentheses expression <code>s</code> is a VPS.</li> |
| 43 | +</ul> |
0 commit comments