Maximum Nesting Depth of the Parentheses - Leetcode 1614 - Python

preview_player
Показать описание


0:00 - Read the problem
0:22 - Drawing Explanation
4:24 - Coding Explanation

leetcode 1614

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

this is one of those problems where trying to read the description is harder than solving the problem itself.

deepfriedtoaster
Автор

Man this is a really straightforward problem. They should have made it so that the parenthesis might not have been valid to make it more fun

AlgorithmArena
Автор

Your explanation skills are insane. Thank you so much. As you started explaining the problem, it leads me to the solution automatically

srikarthickk
Автор

i was about to search this problem and youtube recommended it on homepage.

amongus-rqhb
Автор

I've always implemented this problem with the stack DS which made the space complexity O(n)
Nicely explained 💯

tomiwaadedokun
Автор

great job navdeep congratulations on the coin for a one day streak!

CS_nb
Автор

Probably the easiest leetcode problem ive seen so far.

aptus
Автор

The singular of "parentheses" is "parenthesis" not "parenthesee"

Matthias
Автор

Anything about daily LC 2444. Count Subarrays With Fixed Bounds ?

erminiottone
Автор

I think the code will fail for (() this will give the output as 2 but it is not a valid parenthesis it should give 0 right?

akashreddyjammula
Автор

why didnt u uploaded solution videos for the past few days?

gryffindor
Автор

This was easy, but that description is just asinine like wtf was bro yapping about

torvasdh
Автор

nice to see that our code is almost same:

class Solution:
def maxDepth(self, s: str) -> int:
ans = 0
left, right = 0, 0
for i in s:
if i == "(":
left += 1
elif i == ")":
right += 1
ans = max(ans, left - right)
return ans

BurhanAijaz
join shbcf.ru