Balanced Brackets Matching: Easiest Code using Stack | CP Course | EP 31

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ม.ค. 2025

ความคิดเห็น • 219

  • @manjeetpani4709
    @manjeetpani4709 3 ปีที่แล้ว +62

    10:30 Now this is what I came for and this is what makes your video unique and better than everyone... can't thank you enough ❤️️❤️️❤️️

    • @piyushgarg511
      @piyushgarg511 2 ปีที่แล้ว

      we can use pair instead of unordered map also ??

    • @yourfriendnur
      @yourfriendnur 2 ปีที่แล้ว

      @@piyushgarg511 I think no.Because in case of map we can access value with key(map[key1]+map[key2]==0 or not). But in case of pair we can't do that.

    • @freefiretwo2756
      @freefiretwo2756 ปีที่แล้ว

      @@piyushgarg511 yes we can
      pair p[3] = {{'[',']'},{'(',')'},{'{','}'}};
      string isBalanced(string s) {
      stack bracket;
      for(auto i = s.begin();i!=s.end();i++){
      if(*i=='{' || *i == '['||*i=='('){
      bracket.push(*i);
      }else if(bracket.empty()){
      return "NO";
      }else if(*i==p[0].second && bracket.top()==p[0].first){
      bracket.pop();
      }else if(*i==p[1].second && bracket.top()==p[1].first){
      bracket.pop();
      }else if(*i==p[2].second && bracket.top()==p[2].first){
      bracket.pop();
      }else return "NO";
      }
      if(bracket.empty()) return "YES" ;
      else return "NO" ;
      }

  • @sabbysays
    @sabbysays 3 ปีที่แล้ว +38

    17:23 bhaiya I was literally watching this episode at that same time 😂, goosebumps aa gye the jesei aapne same time bataya.
    Hats off to your dedication. Very inspiring 💙

  • @Wiopr5961
    @Wiopr5961 3 ปีที่แล้ว +83

    By seeing your competitive programming playlist.
    I can't give excuses to myself for not learning Computitve programming.
    Thank you bhai 😍😍😘😘😘😘

  • @codetuber8734
    @codetuber8734 2 ปีที่แล้ว +8

    This is the best++++ channel for programming (not only for competitive programming).
    Bs afsoos ye hai ki jaha paisa dete hai (college) waha Aisa content nhi milta .
    👏❤️❤️

  • @aashishagrawal898
    @aashishagrawal898 3 ปีที่แล้ว +14

    This is just to let you know that this is the first time when someone has explained me "how to code" with such clarity! I am really very amazed and motivated today because of this video playlist.
    thank you luv sir

  • @subhasispanda4960
    @subhasispanda4960 3 ปีที่แล้ว +36

    Lol.. I missed the last blooper part !😂
    Man ! I can't believe you are an engineer and @ 4 am you are teaching us. If we can't like, comment, share and most importantly learn from your amazing contents, this will be so so unfair.
    ❤❤❤❤❤ Hope one day I can meet you !!!🙏🙏🙏

  • @pranjalsingh3071
    @pranjalsingh3071 2 ปีที่แล้ว +12

    I am pretty sure that this channel will grow exponentially because of having Amazing content

  • @vishaljain4642
    @vishaljain4642 3 ปีที่แล้ว +17

    Thank you luv bhaiyya you are putting your love and soul to this playlist ❤️❤️
    You are to amazing that you are making video early in the morning
    I appreciate your Hardwork

    • @iamluv
      @iamluv  3 ปีที่แล้ว +28

      only who has watched till end knows about this xD

    • @manikantasai6118
      @manikantasai6118 3 ปีที่แล้ว +1

      @@iamluv I have watched it bro till end.

  • @HimanshuPathak-mf8bc
    @HimanshuPathak-mf8bc 2 ปีที่แล้ว +2

    bloopers are fun.....do include them.
    And your content obviously is best.

  • @rishabhkumar1170
    @rishabhkumar1170 3 ปีที่แล้ว +1

    Is video ka Blooper sabse best h lol, and thanks a lot luv bhai aap humare liye itni mahenat kr rhe ho :)

  • @AyushSharma-wi8sw
    @AyushSharma-wi8sw 3 หลายเดือนก่อน

    This took me more than 1.5 hrs to implement by myself but was able to do it. Thanks for the series.

  • @mohdzaidkhan7001
    @mohdzaidkhan7001 3 ปีที่แล้ว +1

    bhaiya thanks for the content .and especially jo aap questions add kr dete hain saari videos ke baad haclkerrank ya codeforced ki ,thath"s helping a lot in practising

  • @md.hafizurrahman5436
    @md.hafizurrahman5436 2 ปีที่แล้ว +1

    how underrated you are!!
    It is very disappointed to me.
    This playlist is mind blowing, you deserve at least 1 million.
    Love from Bangladesh!!!

  • @funenjoynilaypatel4553
    @funenjoynilaypatel4553 3 ปีที่แล้ว +3

    I love content of this channel very very helpful and no one gives this level of content

  • @InBracket
    @InBracket 3 ปีที่แล้ว +2

    I never loved c++ but after your video i fall in luv with c++ with luv❤️

  • @ashishbhardwaj6696
    @ashishbhardwaj6696 3 ปีที่แล้ว +53

    I Madara Uchiha , declare you the bestest teacher ever :)

    • @AnoNymOuS-mg9oj
      @AnoNymOuS-mg9oj 3 ปีที่แล้ว +3

      Wake up to reality....

    • @dasanudasanudas
      @dasanudasanudas 3 ปีที่แล้ว

      @@AnoNymOuS-mg9oj then you suggest some?

    • @citrus5127
      @citrus5127 2 ปีที่แล้ว

      naruto ko dekha

    • @Daman1628
      @Daman1628 2 ปีที่แล้ว +1

      He doesn't even remember your name, a fitting end perhaps

    • @ankitjaiswal8496
      @ankitjaiswal8496 2 ปีที่แล้ว

      Best itself is superlative

  • @abhishekhorton79
    @abhishekhorton79 3 ปีที่แล้ว +26

    I was about to quit competitive programming but after start watching your course I started to take part in contest going on and currently 2* coder at codeshef thanks a lot luv bhai.

    • @Ak-um1yg
      @Ak-um1yg 3 ปีที่แล้ว +3

      HOW R U NOW ? any did you improve more?

  • @ritikkhandelwal2358
    @ritikkhandelwal2358 3 ปีที่แล้ว +4

    Luv Bhaiya you are simply amazing
    Can't thankyou much for the course......
    Par loving this.....
    And your efforts are awesome
    Appreciable ♥️

  • @AgnivaBanerjee6
    @AgnivaBanerjee6 3 ปีที่แล้ว +2

    showing segmentation core dumped
    #include
    using namespace std;
    #define pb push_back
    #define pp pop_back
    #define f first
    #define s second
    #define REP(i, a, b) for (int i=a; i m={{'[',1},{'{',2},{'(',3},{']',-1},{'}',-2},{')',-3}};
    string check(string &st)
    {

    stack w;
    for(char bracket: st)
    {
    if(m[bracket]>0) w.push(bracket); //if opening bracket
    else
    {
    if (st.empty()) return "NO";
    int a=m[bracket];
    char topmost=w.top();
    int b=m[topmost];
    if(a+b!=0) return "NO";
    else w.pop();

    }
    }
    if (w.empty()) return "YES";
    else return "NO";
    }
    int main()
    {
    int t;cin>>t;
    while(t--)
    {
    string s; cin>>s ;
    cout

  • @aniketkhajanchi260
    @aniketkhajanchi260 3 ปีที่แล้ว +6

    Please try to attach more practice questions. It is difficult to find good ONLY STL related questions. What we mostly get is mixed complex algorithm questions having the use of STL. It would help a lot. Thanks :)

  • @priyanshuagrawal7509
    @priyanshuagrawal7509 3 ปีที่แล้ว +1

    subah ke 4:50 pe video ban rahe ho hamare lie thank you sirrrr

  • @tirthabarua7366
    @tirthabarua7366 3 ปีที่แล้ว +2

    Great explanation and unique solution ,, sir..😍
    Love from Bangladesh 🇧🇩

  • @god_is_riyal
    @god_is_riyal 3 ปีที่แล้ว +1

    thanks for creating such an informative playlist , i have shared this with my friend so that they too could understand stl in the most easiest way.

  • @Newbie3130
    @Newbie3130 3 ปีที่แล้ว

    First! Bhaiya jiss cheez mein bhi problem aati h na aap jaldi se ussi ki video post kr dete ho..
    Really you are helping a lot
    Matlab maine vector of vector and set of set kayi jagah search kare lekin smjh nhi aaye aapki video se sab smjh aagya...thanks a lot:)

  • @mddinislam5904
    @mddinislam5904 2 ปีที่แล้ว +1

    Masterpiece, Love from Bangladesh....😍😍😍😍😍😍

    • @L.Lawliet_1618
      @L.Lawliet_1618 3 หลายเดือนก่อน

      cp valw mote paren vai?

  • @039saranshvashisht8
    @039saranshvashisht8 3 ปีที่แล้ว +2

    loved the way how easy you made this question😍😍

  • @shakshi9108
    @shakshi9108 3 ปีที่แล้ว +1

    Great explanation🔥...aur bloopers bhi Dekh Kar Maja aata hai😂

  • @marvineriksen7230
    @marvineriksen7230 2 ปีที่แล้ว

    Bhai course to badhiya hai hi aur saath me bloopers dekhke maza aa jaata😂😂😂

  • @vikramvikrant5851
    @vikramvikrant5851 3 ปีที่แล้ว +3

    great approach and explanation 👌

  • @burning9708
    @burning9708 2 ปีที่แล้ว

    Definitely best implementation.
    Rich content indeed.
    ~Take ♥ from Bangladesh

  • @iamgroot2810
    @iamgroot2810 3 ปีที่แล้ว +3

    Thanks a lot for this playlist!

  • @rasikaphutke8501
    @rasikaphutke8501 3 ปีที่แล้ว +1

    Love your way of solving it differently sir !!

  • @DHIRAJKUMAR-iw3dj
    @DHIRAJKUMAR-iw3dj 2 ปีที่แล้ว

    awesome bro i saw this problem & solution multiple time but this solution is pretty more better

  • @omraja404
    @omraja404 3 หลายเดือนก่อน

    8:36 I have a doubt : When do we take input of test cases and when not ?

  • @AppaniMadhavi
    @AppaniMadhavi ปีที่แล้ว

    U made Medium to hard problem as very very easy, thank you bro..❣

  • @manojkumar-qm4mx
    @manojkumar-qm4mx 3 ปีที่แล้ว

    Aap bahut hi badhiya padhate ho

  • @TheAuraa
    @TheAuraa 3 ปีที่แล้ว

    BEST APPROACH FOR THIS PROBLEM ON TH-cam

  • @parthkabra8880
    @parthkabra8880 3 ปีที่แล้ว +2

    17:16 best part of the video🤣😂😂🤣😂😂

  • @avibirla9863
    @avibirla9863 3 ปีที่แล้ว

    What a unique approach ♥️♥️ Ly bhaiya ..I think this approach is not available on entire youtube except Luv ✌✌

  • @sarwat3552
    @sarwat3552 3 ปีที่แล้ว +1

    Brroooo,I was waiting for this 🔥🔥❤️

  • @hasibuddin5216
    @hasibuddin5216 ปีที่แล้ว

    Best teacher I have ever seen

  • @RituKumari-hx5on
    @RituKumari-hx5on 3 ปีที่แล้ว +1

    Your explanation are really rock. Thank you soo much😊😊

  • @josteins4501
    @josteins4501 3 ปีที่แล้ว +1

    Awesome approach Bro!! Much appreciated.

  • @roy_enigma
    @roy_enigma ปีที่แล้ว

    salute to see your hardwork bhiya , and thanks for the playlist . ❤

  • @jayadubey_22
    @jayadubey_22 3 ปีที่แล้ว +2

    thank you so much for such videos
    You explain as if I am teaching myself 👌👌

  • @badalwanjari4964
    @badalwanjari4964 3 ปีที่แล้ว +1

    👏👏👏 appreciation for your efforts ❤️

  • @roshangupta8161
    @roshangupta8161 3 ปีที่แล้ว

    Bloopers made this content enjoyable.

  • @prabhootpatel1654
    @prabhootpatel1654 ปีที่แล้ว

    bhai saahab code ho toh aisa !!! maza aa gaya logic dekh ke

  • @sp-bp4fr
    @sp-bp4fr 3 ปีที่แล้ว

    Mza aa gya unordered Map wla code dekh k

  • @parth8370
    @parth8370 3 ปีที่แล้ว +1

    You are doing a great work broo..🔥

  • @KaranKumar-qi7er
    @KaranKumar-qi7er 3 ปีที่แล้ว

    simple and unique idea to solve problem

  • @sippy8482
    @sippy8482 3 ปีที่แล้ว

    ❤️❤️best cp content on utube...u will get 100k subs within a month I know...

  • @pranshul..
    @pranshul.. 3 ปีที่แล้ว +2

    Commenting for better reach
    Mast content op yeah sab bhi likh skta hu per ( gold/ 💎) ko bolna tum expensive ho bolna nhi ho jaayega 🤔😅

  • @abhijeetsingh9796
    @abhijeetsingh9796 3 ปีที่แล้ว

    Luv sir we appreciate your efforts and INT_MAX love from a freshie from your college
    ❤️❤️

  • @ravitripathi9725
    @ravitripathi9725 3 ปีที่แล้ว

    Luv bhaiya ide k liye kux recommend kijiye c++ k liye m filhal atom use krra hun and mera vs code bht zyaada bug show krra h I don't know how to resolve it
    Very nyc explaination you are giving loving it👍👍👍

  • @sonukumarnirala6896
    @sonukumarnirala6896 8 หลายเดือนก่อน +1

    Excellent Gurujii

  • @thearnavagg
    @thearnavagg 3 ปีที่แล้ว

    Wow aap subhe bhut jaldi uthe ho. Vese jaldi utne ki koshish ki and bhut productive jata hai din

    • @iamluv
      @iamluv  3 ปีที่แล้ว +1

      jldi uthta nhi hu.. late sota hu.. 👀

    • @thinkingmad1685
      @thinkingmad1685 3 ปีที่แล้ว

      @@iamluv same bhai raatko mujhe productive hota hai

  • @aptitudepointiit-bhu5358
    @aptitudepointiit-bhu5358 3 ปีที่แล้ว +3

    We can also use the difference in ASCII values of string value and the topmost
    element of the stack,
    CODE:
    if( s.empty()==false && (str[i] - s.top())

  • @piyushgarg511
    @piyushgarg511 2 ปีที่แล้ว

    10:30 we can use pair instead of unordered map also ??

  • @AyushSingh-he8ob
    @AyushSingh-he8ob 3 ปีที่แล้ว

    Best explanation till date

  • @kundanrajpoot212
    @kundanrajpoot212 2 ปีที่แล้ว +1

    St. pop(), hmlog if condition ke baad else mein rkhte toh sahi rhta?

  • @omraja404
    @omraja404 3 หลายเดือนก่อน

    18:00 wo kya hai ? wo kon sa device hai ???

  • @debaratighatak2211
    @debaratighatak2211 3 ปีที่แล้ว

    such an elegant code! :D wow❤️️

  • @404-p8i
    @404-p8i 3 ปีที่แล้ว

    And again you rocked it bro!!

  • @RituKumari-hx5on
    @RituKumari-hx5on 3 ปีที่แล้ว +1

    As Unordered map do not allow duplicate keys, If the brackets repeats in that case it wont work?

  • @jatinranjan7954
    @jatinranjan7954 2 ปีที่แล้ว

    BEST !! CP course

  • @whoisprafull
    @whoisprafull 3 ปีที่แล้ว

    Thanks from bottom of my heart .🙏

  • @abhimannyumagar1033
    @abhimannyumagar1033 3 ปีที่แล้ว

    Baground music is so good 😊

  • @krishnanandyadav9248
    @krishnanandyadav9248 2 ปีที่แล้ว +2

    I didn't understand the code in line 13, why are we popping the stack, even though we haven't yet checked whether the top element is complementary to the bracket value or symbols[top] + symbols[bracket] ==0 or not, shouldn't we only pop when the opening bracket is same as closing bracket

    • @BOSS55
      @BOSS55 ปีที่แล้ว

      Yes you are right i am also confused.

  • @ahmedreza1755
    @ahmedreza1755 3 ปีที่แล้ว +1

    Thanks for your effort sir !!

  • @131dash9
    @131dash9 2 ปีที่แล้ว

    u are amazing . thnx for ur hardwork.

  • @sakshamgarg5985
    @sakshamgarg5985 3 ปีที่แล้ว

    can you use some different variable name in char top= st.top() 14:35

  • @AhmadMaqsood-j4v
    @AhmadMaqsood-j4v ปีที่แล้ว +1

    thanks bro its morning 4.50 am

  • @binarycode07
    @binarycode07 2 ปีที่แล้ว

    best_teacher_ever 🔥🔥🔥

  • @diwakarkumar3015
    @diwakarkumar3015 2 ปีที่แล้ว +1

    this code is showing error brace-enclosed initializer list
    how to remove this

  • @SadhanaSharma
    @SadhanaSharma 2 ปีที่แล้ว

    u explain so well .woww☺

  • @horccruxxxop4184
    @horccruxxxop4184 2 ปีที่แล้ว

    Bhai ek doubt h if we take string"= { ]"
    Then your code goes wrong
    Qnki wo for loop ke else me jaga Jaha wo empty check krega but wo hai ni to aage bdhega Fir wo pop krega and then compare to NO print krega but Jb wo pop krega to "{" Nikl jaega aur stack empty hojaega to... For ke bahar wle me jo empty check kr rhe us pr yes print krdega
    So output NO YES AEGA ABOVE STRING KA..?;

  • @hridamchakraborty6032
    @hridamchakraborty6032 3 ปีที่แล้ว +2

    Please explain symbols[brackets] and symbols[top]

    • @iamluv
      @iamluv  3 ปีที่แล้ว

      i am just using the unordered map, watch maps and unordered maps episode once if you havent watched it

  • @UECAshutoshKumar
    @UECAshutoshKumar 2 ปีที่แล้ว +1

    Thank you sir ❤️

  • @stevefox2318
    @stevefox2318 3 ปีที่แล้ว +1

    Thanks buddy 😊😊

  • @Nitro-kx7ok
    @Nitro-kx7ok 2 ปีที่แล้ว

    Understood sir❤🙇‍♂🙏

  • @kanandnaik5677
    @kanandnaik5677 3 ปีที่แล้ว

    can we check palindrome of , by this balanced bracket matching ?

  • @aman_sahu
    @aman_sahu 3 ปีที่แล้ว +1

    great series

  • @abhaypratap9898
    @abhaypratap9898 3 ปีที่แล้ว +1

    Love you bhaiya ❤️

  • @jugal.suthar
    @jugal.suthar 3 ปีที่แล้ว

    thankyou for this amazing content🤗.

  • @subhasispanda4960
    @subhasispanda4960 3 ปีที่แล้ว +1

    Your logic is awesome but I think we can have a simpler approach by using unordered_map
    string isBalanced(string s)
    {
    unordered_map symbol = {{'(', ')'}, {'{', '}'}, {'[', ']'}};
    stack st;
    for (char bracket : s)
    {
    if (symbol.find(bracket) != symbol.end())
    st.push(bracket);
    else if (st.empty() || bracket != symbol[st.top()])
    return "NO";
    else
    st.pop();
    }
    if (st.empty())
    return "YES";
    return "NO";
    }
    As this is a very popular question, so hope this code helps.
    And thanks luv bhai.. sab aap ka sikhaya hua he..🙏

  • @sippy8482
    @sippy8482 3 ปีที่แล้ว +2

    Can u please upload that topic String algorithm and dp as soon as possible🥺

    • @iamluv
      @iamluv  3 ปีที่แล้ว +6

      after stl, i am going to cover numbery theory bit manipulation graph theory and then will come dp. We are going in order here.

    • @sippy8482
      @sippy8482 3 ปีที่แล้ว

      @@iamluv ❤️❤️thnku for reply😊

  • @papul6
    @papul6 3 ปีที่แล้ว +1

    Super video bro 🇮🇳🌹🇮🇳

  • @utkarshsrivastava4192
    @utkarshsrivastava4192 ปีที่แล้ว

    we can solve above problem by using vector in same time,space complexity...then what is the point of using stack

  • @parthkabra8880
    @parthkabra8880 3 ปีที่แล้ว

    all: teaching first
    me: bloopers first

  • @hritik7648
    @hritik7648 3 ปีที่แล้ว

    why did u add st.pop() in line 13 ? what is the need of that ?

  • @divyanshurawat2422
    @divyanshurawat2422 3 ปีที่แล้ว +1

    symbols[top] + symbols[bracket]
    but in top and bracket there is character value , how the compiler have picked integer value.

    • @arpitsrivastava606
      @arpitsrivastava606 3 ปีที่แล้ว

      symbols[top] ek map hai isske corresponding hmne int value store ki hai jese
      map['(']=-2 ; map[')']=2

  • @joydeb8202
    @joydeb8202 3 ปีที่แล้ว +1

    One day my junior will ask best TH-cam channel for C.P. and I will suggest this one.. Totally awesome and precise, concrete and crisp content....
    Bhaiya just increase the frequency of videos(if possible, I know this type content is difficult to make)

    • @iamluv
      @iamluv  3 ปีที่แล้ว +4

      I post 2 videos a week. Cant increase more than that. This only is difficult

    • @joydeb8202
      @joydeb8202 3 ปีที่แล้ว

      ❤️❤️

  • @ayushbhandari1983
    @ayushbhandari1983 2 ปีที่แล้ว

    sir you used st.pop() before the condition why so ?

  • @Nhpkgaming
    @Nhpkgaming 3 ปีที่แล้ว +1

    God bless you bahi

  • @aakarshitrekhi8071
    @aakarshitrekhi8071 3 ปีที่แล้ว +1

    what a clever solution loved it

  • @Jarurathai
    @Jarurathai ปีที่แล้ว

    Bhaiya mera ye code
    Input - (
    Ke liye balanced bta rha hai..
    Please koi help kro 🙏

  • @Tech-ij8lj
    @Tech-ij8lj 3 ปีที่แล้ว

    Bro unordered map m to duplicate value store n hoti to Agr string m open bracket 2 baar aye to unordered map to use ek hi baar manega

  • @aayush5474
    @aayush5474 3 ปีที่แล้ว

    unordered map thing was smart :D

  • @yashitabansal3652
    @yashitabansal3652 2 ปีที่แล้ว

    can u pls solve the ques dense brackets using stack. I m a bit stuck writing the code. please help me out