Max Consecutive Ones III | Leetcode June Challenge | Leetcode 1004 | Approach + Code | C++ | Python

Sdílet
Vložit
  • čas přidán 28. 06. 2021
  • C++ Code Link : github.com/Ayu-99/Data-Struct...
    Python Code Link: github.com/Ayu-99/Data-Struct...
    Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)
    #leetcode
    #leetcodeJuneChallenge
    #interviewpreparation
    Max Consecutive Ones III solution
    Max Consecutive Ones III Leetcode
    Max Consecutive Ones III C++
    Max Consecutive Ones III C++ Hindi
    Max Consecutive Ones III Hindi
    Checkout the series: 🔥🔥🔥
    👉 Recursion : • Recursion
    👉 Stack and Queue : • Stack And Queue
    👉 Greedy : • Greedy
    👉 Leetcode contests : • Leetcode contests
    👉 Leetcode June Challenge : • Leetcode June Challenge
    LIKE | SHARE | SUBSCRIBE 🔥🔥😊

Komentáře • 70

  • @devanshdixitmusicallyyours3885

    pls make more such videos , u have literally explained this problem so amazingly... thank u

  • @phantom3612
    @phantom3612 Před 7 měsíci

    Understood! thanks.
    C++ implementation ---
    //ALGORITHM: Basically we see arr, we see k. Voila!\
    //Sliding window problem. Now to tackle this.
    //We take i=j=0. ans=0 and zerocount=0
    //Basically, j will keep on moving till
    //we our zerocount > k. At that point.
    //we first do ans = max(ans, j-i+1)
    //next obv, we need to move i (that is,
    //sliding the fucking window.)
    //Now till when? Glad you asked!
    //We do it until we get a pass! (i.e. our
    //zerocount becomes equal to k
    //at that point we simply go back to moving j
    //untill we see another 0 focring us to incrment
    //zerocount. Thus the steps repeat)
    int longestSubSeg(vector &arr , int n, int k){
    int i=0, j=0, ans=0, zerocount=0;
    while(j

  • @ninadkheratkar6716
    @ninadkheratkar6716 Před rokem

    Thank you for the detailed explanation!

  • @vivekswami2182
    @vivekswami2182 Před rokem

    Really amazing explanation, loved it !!

  • @robinofautumn99
    @robinofautumn99 Před 4 měsíci

    was half way through your video, but completely understood the concept... thanks Di😄😄😄😄

  • @mayank_singh_43
    @mayank_singh_43 Před rokem

    Awsm explaination, best on utube

  • @RahulVerma-fz2jf
    @RahulVerma-fz2jf Před rokem +1

    Great job. Explanation is really clear. After this, I hope I don't mess the implementation again in the interview.

  • @sanskarsinghh
    @sanskarsinghh Před 11 měsíci

    Thank you for the crystal clear explanation didi :)

  • @tot7997
    @tot7997 Před rokem

    thanks a lot.. amazing explanation ❤

  • @anupkhismatrao9280
    @anupkhismatrao9280 Před rokem

    Amazing explanation ❤

  • @krishnavamsichinnapareddy

    Very good explanation 👍

  • @VijayPatel-ez4lp
    @VijayPatel-ez4lp Před rokem +1

    thanku mam
    nice explanation

  • @suruchikumari8371
    @suruchikumari8371 Před 11 měsíci

    Today i visit your channel first time while facing difficulties solving this problem.... really you explained very well dii...now my all doubts are cleared about two pointer approach.....

  • @abhaythakur2597
    @abhaythakur2597 Před rokem

    very well explained

  • @AkashYadav-po5kb
    @AkashYadav-po5kb Před rokem

    Phli ladki dekho hai jiski coding itni acchi h , very good explanation, keep it up and subscribed👍

  • @GhostRider....
    @GhostRider.... Před rokem

    nice explanation

  • @nomore_alive9262
    @nomore_alive9262 Před 3 měsíci

    Koi chakkar ni🤘🤘

  • @Akash-Bisariya
    @Akash-Bisariya Před 10 měsíci

    Thanks for explaining so nicely!!

  • @shripadkhandare
    @shripadkhandare Před 3 měsíci

    Thanks For Nice explanation.

  • @nandiniverma5273
    @nandiniverma5273 Před 6 měsíci

    Very Good Dry run , thanks

  • @RohitGupta-xf3zp
    @RohitGupta-xf3zp Před 8 měsíci

    Thanks dii very easy and clear explanation.

  • @ankitnishad7831
    @ankitnishad7831 Před rokem

    I tried this question by myself but couldn't make through some cases nice explanation got to know what I was mistaking.

  • @beastcracker117
    @beastcracker117 Před 10 měsíci

    Shukria ❤

  • @harshexploring4922
    @harshexploring4922 Před rokem

    The explaination was really great

  • @rushikeshubale3478
    @rushikeshubale3478 Před 10 měsíci

    Nice explanation. Thanks!

  • @tusharjeena7081
    @tusharjeena7081 Před rokem

    mam your voice is so sweet

  • @ashutoshbajpai3133
    @ashutoshbajpai3133 Před rokem

    great explaination

  • @user-ze3mk9wk5c
    @user-ze3mk9wk5c Před 3 měsíci

    useful

  • @rahulsati5819
    @rahulsati5819 Před rokem

    thnks amazing explanation

  • @amanranjan2684
    @amanranjan2684 Před rokem

    thx

  • @divyansh1391
    @divyansh1391 Před rokem

    thanks di❤

  • @davinder95
    @davinder95 Před rokem

    dusre while ki jagah if b chl jata no need to used two whiles

  • @vishalsrivastavavishalsri92
    @vishalsrivastavavishalsri92 Před 8 měsíci

    For input "111000" and k=1 the answer should be 3 but your code will give 4 since there is no information about the number of 1s.

    • @Ramneet04
      @Ramneet04 Před 7 měsíci

      I think it should be 4 only . Why do you think its going to be 3???

  • @chandlerbing8164
    @chandlerbing8164 Před 4 měsíci

    to draw do you use mouse only or graphics tablet or you have touch screen ?

  • @AdityaSingh-li4km
    @AdityaSingh-li4km Před 10 měsíci

    Hello ,
    can u ecplain why this works ?
    zeros, l = 0, 0
    for r, n in enumerate(nums):
    zeros += n == 0
    if zeros > k:
    zeros -= nums[l] == 0
    l += 1
    print(r,l,len(nums))
    return r - l + 1

  • @adj5951
    @adj5951 Před 4 měsíci

    I think you should explain more clearly, it was a bit complex to understand, i understood the concept, but then how to play with i and j was a bit difficult to comprehend

  • @exploringworld6817
    @exploringworld6817 Před 3 lety

    Time complexity kya rahegi?

  • @aishwaryarathod5421
    @aishwaryarathod5421 Před 3 lety

    oyy dii,, its not sliding window
    its two pointer method

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Před 3 lety +5

      Oyy geeks, we are maintaing a window having at most k zeros everytime. It's sliding window🙂

    • @exploringworld6817
      @exploringworld6817 Před 3 lety

      @@AyushiSharmaDSA epic reply😂

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Před 3 lety

      @@exploringworld6817 😂😂😅

    • @aishwaryarathod5421
      @aishwaryarathod5421 Před 3 lety

      🥸🥸,, your ans is like
      I'm justifying my ans with the reason you use 2 pointers🙂.

    • @AyushiSharmaDSA
      @AyushiSharmaDSA  Před 3 lety +1

      @@aishwaryarathod5421 Bro, there are different approaches. You can try whichever you like. 😃

  • @sahilverma4142
    @sahilverma4142 Před 3 lety +1

    Phir Level add ni kiye😔

  • @user-gv9wm2oi3h
    @user-gv9wm2oi3h Před 6 měsíci

    nice explanation