solved it on my own🥳🥳 Thanks to u class Solution { public: int maxDepth(string s) { int result=0; int cnt=0; for(auto &ch:s){ if(ch=='('){ cnt++; result=max(result,cnt); } if(ch==')')cnt--; } return result; } };
Sir I solved it using string as a stack. I push_back(s[i]) when s[i] is '(' and pop_back() when s[i] is ')'. I have heard that sometimes strings also add to space complexity. So my question is, using string as a stack will add to space complexity or will it be O(1) space? Thanks in advance!!
Hi sir can u plz make a video on lc 301...which is remove invalid parenthesis. Even though its a very popular problem but no proper explanation exists on yt for this problem . Thank u.
The question was really simple but the over explanation of leetcode made it complex. Thanks a lot bhaiya for such a great explanation ❤❤
thank you bro. your explanation helps me to do the code by myself! codestorywithmik is vaardhaan for me!
solved it on my own🥳🥳
Thanks to u
class Solution {
public:
int maxDepth(string s) {
int result=0;
int cnt=0;
for(auto &ch:s){
if(ch=='('){
cnt++;
result=max(result,cnt);
}
if(ch==')')cnt--;
}
return result;
}
};
great same method i also solve
Amazing explanation
java code guyz..
class Solution {
public int maxDepth(String s) {
int n=s.length();
int openCounts=0;
int res=0;
for(int i=0;i
Thank you sir 🙏very nice explanation👌
Nice 👌🏻
Sir I solved it using string as a stack. I push_back(s[i]) when s[i] is '(' and pop_back() when s[i] is ')'. I have heard that sometimes strings also add to space complexity. So my question is, using string as a stack will add to space complexity or will it be O(1) space? Thanks in advance!!
It will add to space complexity because it’s an extra data structure you have taken.
@@codestorywithMIK Sir Please make video on this question of gfg, Friends Pairing Problem(DP)
congratulations on 39k. soon 1M.
Just matter of some time when people will discover your content and it will go boom.
Thank You!
nice
hats off to the consistency
I was able to do it on my own using stack but approach-2 didn't occur to my mind. thanks
Hi sir can u plz make a video on lc 301...which is remove invalid parenthesis. Even though its a very popular problem but no proper explanation exists on yt for this problem . Thank u.
Done and dusted. Leetcode should put your explanation as the official explanation 😅
Good explanation 👏 🎉
Good morning bhai ❤
Sir isme aapne assume kia ha kya ki string Valid parenthesis ha hi?
It’s given in constraints.
During interviews, always ask and confirm before hand.
Yes Got it sir... Sir your videos have helped me lot in Intuition building and watch ur videos everyday without fail. 👌
class Solution {
public:
int maxDepth(string s) {
int ans = 0;
int cnt = 0;
for(int i = 0;i
bhaiya agar time mile toh iss bar ke weekly aut bi-weekly contest ka q4 karwa dena.
bhaiiyaa 3102. Minimize Manhattan Distances isko smjhado plzzzz
At 5:45 dekh th 3 hobga ha ........
Qn ko utha k phek diya 😅