Maximum Nesting Depth of the Parentheses | 2 Approaches | Leetcode 1614 | codestorywithMIK

Sdílet
Vložit
  • čas přidán 6. 09. 2024

Komentáře • 28

  • @gauravbanerjee2898
    @gauravbanerjee2898 Před 5 měsíci +11

    The question was really simple but the over explanation of leetcode made it complex. Thanks a lot bhaiya for such a great explanation ❤❤

  • @spdh6325
    @spdh6325 Před 5 měsíci +4

    thank you bro. your explanation helps me to do the code by myself! codestorywithmik is vaardhaan for me!

  • @oqant0424
    @oqant0424 Před 5 měsíci +2

    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;
    }
    };

  • @tutuimam3381
    @tutuimam3381 Před 5 měsíci +2

    Amazing explanation

  • @thaman701
    @thaman701 Před 5 měsíci +2

    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

  • @jaydeepkaware3960
    @jaydeepkaware3960 Před 5 měsíci +1

    Thank you sir 🙏very nice explanation👌

  • @Momentsofmagic28
    @Momentsofmagic28 Před 5 měsíci

    Nice 👌🏻

  • @abhishektripathi3904
    @abhishektripathi3904 Před 5 měsíci +1

    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!!

    • @codestorywithMIK
      @codestorywithMIK  Před 5 měsíci

      It will add to space complexity because it’s an extra data structure you have taken.

    • @parthbhatia7125
      @parthbhatia7125 Před 5 měsíci

      @@codestorywithMIK Sir Please make video on this question of gfg, Friends Pairing Problem(DP)

  • @EB-ot8uu
    @EB-ot8uu Před 5 měsíci

    congratulations on 39k. soon 1M.
    Just matter of some time when people will discover your content and it will go boom.

  • @kunalpatil.24
    @kunalpatil.24 Před 5 měsíci +1

    Thank You!

  • @mdshahnawaz645
    @mdshahnawaz645 Před měsícem

    nice

  • @wearevacationuncoverers
    @wearevacationuncoverers Před 5 měsíci

    hats off to the consistency

  • @souravjoshi2293
    @souravjoshi2293 Před 5 měsíci

    I was able to do it on my own using stack but approach-2 didn't occur to my mind. thanks

  • @prajwalshaw9217
    @prajwalshaw9217 Před 5 měsíci

    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.

  • @aws_handles
    @aws_handles Před 5 měsíci

    Done and dusted. Leetcode should put your explanation as the official explanation 😅

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Před 5 měsíci

    Good explanation 👏 🎉

  • @sameerswankar
    @sameerswankar Před 5 měsíci +1

    Good morning bhai ❤

  • @jeehub041
    @jeehub041 Před 5 měsíci +1

    Sir isme aapne assume kia ha kya ki string Valid parenthesis ha hi?

    • @codestorywithMIK
      @codestorywithMIK  Před 5 měsíci

      It’s given in constraints.
      During interviews, always ask and confirm before hand.

    • @jeehub041
      @jeehub041 Před 5 měsíci +1

      Yes Got it sir... Sir your videos have helped me lot in Intuition building and watch ur videos everyday without fail. 👌

  • @utkarshsahay9908
    @utkarshsahay9908 Před 5 měsíci +1

    class Solution {
    public:
    int maxDepth(string s) {
    int ans = 0;
    int cnt = 0;
    for(int i = 0;i

  • @dhairyachauhan6622
    @dhairyachauhan6622 Před 5 měsíci

    bhaiya agar time mile toh iss bar ke weekly aut bi-weekly contest ka q4 karwa dena.

  • @jatinchandel7179
    @jatinchandel7179 Před 5 měsíci

    bhaiiyaa 3102. Minimize Manhattan Distances isko smjhado plzzzz

  • @devmadaan5146
    @devmadaan5146 Před 5 měsíci

    At 5:45 dekh th 3 hobga ha ........

  • @user-ub2is4rs4x
    @user-ub2is4rs4x Před 5 měsíci

    Qn ko utha k phek diya 😅