Window Sliding Technique | Why? What? When? How? | Comparison, Code Identification of Questions

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

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

  • @sdef719
    @sdef719 4 ปีที่แล้ว +6

    The explanation why this approach falls under dynamic programming is great. Learned a new lesson. Thanks ma'am.

  • @matrixRule127
    @matrixRule127 4 ปีที่แล้ว +13

    Actually, I was asked the same problem in my Paypal interview, but it didn't go well for me. Glad to actually find this. Awesome explanation. Thank you! 😍

  • @saiyashwanth1991
    @saiyashwanth1991 4 ปีที่แล้ว +16

    it's a pattern when you need to find something in the contiguous sub-array.

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

    Your intution to clear the topic meaning is very effective...as i understand it in one go!

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

    Nice explanation mam ....you explained it from the scratch itself ,this is the first video I am watching in this channel and am impressed and subscribed as well... keep doing on this topics

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

    I always love this sliding window approach! Whenever I get a prob on maximum sum subarray or product subarray,I apply this technique with happiness!😂🔥

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว +1

      Yeah, once you know this, it becomes easy😇

  • @Shredder220
    @Shredder220 4 ปีที่แล้ว +1

    Your way of teaching is way more good than those highly paid tutorials...waiting for your next video like this maam

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว +1

      Thank you 😇😇
      Many videos coming up!!

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

    Thank you so much for the wonderful explaination, now I got some basic idea of Window Sliding technique

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

    awesome video Keerti.. Nice explanation... I'm making this my classroom from henceforth.. in the second loop, it should be arr[I] instead of arr[k] Thanks..

  • @tombrady7390
    @tombrady7390 4 ปีที่แล้ว

    your channel is small ,but you can be appreciate the fact that you helped the community and impacted us positively thanks :)

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

    M super glad that this video is in English !

  • @snehitvaddi
    @snehitvaddi 4 ปีที่แล้ว +1

    Great explanation yar!! I could literally visualize everything by your hand gestures itself!! 👏👏👏

  • @TUSHARSHARMA-zr1fc
    @TUSHARSHARMA-zr1fc 2 ปีที่แล้ว

    You explain so good, with no wastage of time....
    Love ur videos❤

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

    I subscribed to your channel after watching several videos on your channel. Your videos focus on core concepts of topic and not just the particular problem(which other youtubers do) due to which we get a good sense of where these concepts can applied. Keep posting such videos❤️

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

      can you tell which videos are focusing on core concepts? even i have faced the same problem on other youtubers videos

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

    One of the most underrated channel fr

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

      Please do help in removing the underrated part and share the channel with your friends. It will mean a lot to me! 😇❤️

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

    best video on window sliding

  • @abcdabcd8605
    @abcdabcd8605 7 หลายเดือนก่อน +1

    There is a mistake in the code at line line 6,
    it should be,
    wind_sum += arr[i] -arr[i-k];
    and not as
    wind_sum = arr[i] -arr[i-k];

  • @jitendraraghuwanshi1365
    @jitendraraghuwanshi1365 4 ปีที่แล้ว +1

    One of my favourite techniques for arrays ,btw a great video!

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

    mam ur explanation is too good

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

    Hi Keerthy,
    Thanks for the content.
    I tried this in Python
    lst_2 = [1,2,3,4,5,6,7,8,9,10]
    k=5
    wind_sum=0
    for i in range(k):
    wind_sum=wind_sum+lst_2[i]
    max_sum = wind_sum
    for j in range(k,len(lst_2)):
    next_wind_ele = lst_2[j] - lst_2[j-k]
    wind_sum+=next_wind_ele
    max_sum = max(wind_sum,max_sum)
    print(max_sum)

  • @DevLife_in
    @DevLife_in 4 ปีที่แล้ว +1

    It was a great video Mam, I loved it. I don't even know about you in my past but i loved it.

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

    The sliding window technique is my favourite one. Great explanation though !!

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

    The video is very well explained and detailed. Great work.

  • @rudraksh9635
    @rudraksh9635 4 ปีที่แล้ว

    Oh gosh , this is much awaited !!! Thanx a lot ma'am .. want more such videos , two pointer approach ! Btw loved ur content ma'am , thank you ma'am

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว

      I have discussed little biy about the two pointer approach in the end.
      My next video will be on that completely 😊

    • @rudraksh9635
      @rudraksh9635 4 ปีที่แล้ว

      @@KeertiPurswani sure maam , would be looking forward for the same , just increase ur content frequency by bit maam , if possible ..

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

      @@KeertiPurswani Hi ma'am, when can we expect the two pointer approach video?

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

    I really love your way of teaching, keep going di! 😃

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

      Thank you so much Harshita, means a lot to me ❤️

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

    Thank you nice one

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

    One more error to be noted in the coding you wrote- it should have been : arr[ i ] - arr[i - k] instead of arr[ k ] - arr[i - k] .

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

    Hi Keerti,
    Nice explanation, but I think it is missing an edge case, what if nums[] is less than k, lets say nums.length = 3, whereas k = 5, in that case it will give ArrayOutOfBound Exception.
    My version of code, though I learned this concept from you :)
    static int maxMovingAvg(int[] nums, int k) {
    int i = 0;
    int result = 0;
    if (nums == null || nums.length == 0) return result;
    if (nums.length == 1) return nums[0];
    if (nums.length < k) k = nums.length;
    while (i < k) {
    result += nums[i];
    i++;
    }
    int maxResult = result;
    while (i < nums.length) {
    result += nums[i];
    result -= nums[i - k];
    maxResult = Math.max(maxResult, result);
    i++;
    }
    return maxResult;
    }
    public static void main(String[] args) {
    //int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    //int[] nums = {1, 2, 3, 4};
    //int[] nums = {1, 2, 3};
    //int[] nums = {1, 2};
    //int[] nums = {1};
    //int[] nums = {};
    int[] nums = null;
    int maxResult = maxMovingAvg(nums, 3);
    System.out.println(maxResult);
    }

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

    Awesome, thank you!

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

    Very well explained topic 👍👍.

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

    Very good explanation

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

    HI Keerthi, Great job as always. Little curious at 9:41 shouldn't it be arr[i] instead of arr[k]?

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

      yes bro .. i was finding where the bug was thanks for the comment🙂🙂🙂

  • @sprajwal-lq3zz
    @sprajwal-lq3zz ปีที่แล้ว

    great explanation thanks.

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

    found an error... maybe?
    in your second loop, you are just taking diff of a[k] and a[k-i].. you need to include the maxsum as well.. otherwise the max() comparison won't make sense..
    thoughts?

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

    Nice explanation

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

    I like the way you had explained this video because I was able to understand this completely, I do not see the continuation video for dynamic window size, Are you planning to upload it?

  • @ashutoshkumar4267
    @ashutoshkumar4267 4 ปีที่แล้ว

    Great explaination, Thanks

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

    really helpful

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

    I know it seems a little late but ur code is incorrect it should be currentSum += arr[i] - arr[i-k];

  • @ranitdey7369
    @ranitdey7369 4 ปีที่แล้ว +1

    Your way of explaining the concepts is fabulous. keep it up!

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว

      Thank you. Means a lot! 😇😇

  • @jatinmalhotra2117
    @jatinmalhotra2117 4 ปีที่แล้ว

    very good explanation ! 👍

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

    Hi di, could you able ot provide the link to solving a problem of variable window size?

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

    very helpful!

  • @pawanagrawal7653
    @pawanagrawal7653 4 ปีที่แล้ว

    Mam ur videos are very good, i have understood the concept very nicely..
    Plss make a video on which covers all the algorithms like greedy, divide and conquer etc..and also attached some questions based on them...it will be very grateful.

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว +1

      Definitely!
      Many videos coming up 😇

  • @aryankhurana1847
    @aryankhurana1847 4 ปีที่แล้ว

    Awesome!

  • @bhanuchirutha
    @bhanuchirutha 4 ปีที่แล้ว

    I didn't see the warning at 10:12 and thinking how this code works

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

    any real use case?

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

    Helpful

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

    There is a small error in the code you have written. In first line of second loop the code should be window_sum += arr[k] - arr[i-k].
    You have written window_sum = arr[k] - arr[i-k]

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

    Hi Keerti, Thanks for your awesome videos. Can you please create a dynamic programming concepts videos on how to identify and approach problems, find substructures etc. (if you already haven't).

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

    Shouldn't it be a[I] - a[i-k] ?? How we gonna slide if k is constant with a[k]-a[i-k] . Great explanation though , thanks

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

    correct me if i wrong , but ig there at the loop k to n : you forgot to mention that we include the next element(after k elements )and excluded the first element i.e sliding the window .. you just did arr[i-k]-arr[k] which ig is not correct ... apart from this the concept explanation is fab..

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

    Hey Keerti your videos are very detailed and still easy to understand. Just watched few of ur videos and they were awesome. My fav is BFS and DFS detailed video.Can u suggest some reading resources that will help. Thanks a lot :)

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

      Thank you so much Sonu. Means a lot. I have generally read from gfg, cracking the coding Interview by Gayle Lakman and Karumanchi 😇

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

    I like the way u say hi and I like ur voice

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

    wondering why 2 for loops are needed when it can be done by 1 while loop as below. here is the python solution.
    arr=[1,2,4,3,2 1,5]
    maxsubarray=[]
    maxsum = 0
    k =3
    i=0
    while (i < len(arr) -1 and ( i + k)

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

    Hello mam, you had mistake on 9.42 it's arr[ i ] is not an arr[ k ] when you teaching it was right but you wrote accidentally wrong.

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

    code is wrong it should be wind_sum += arr[i] -arr[i-k];

  • @suyashmisra7406
    @suyashmisra7406 4 ปีที่แล้ว

    Dear Ma'am,Thanks a lot for these tutorials. They are really helpful.
    I have a request ,if you don't mind. I'd love it if you could share some guidance on "off campus" placements,regarding anything "extra" that one must keep in mind while applying off campus. Since I have no experience of it,any help will be appreciated.
    Thanks in advance!

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว

      Was planning this already after few videos 😊

    • @suyashmisra7406
      @suyashmisra7406 4 ปีที่แล้ว

      @@KeertiPurswani Really appreciate it. Can't wait!

  • @venkatkuncham2332
    @venkatkuncham2332 4 ปีที่แล้ว +1

    Try with a gud mic,ur channel will go upto 1lakh subscribers easily (hoping to reach 1m😁),I like the way you explain.

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

    Hello, your videos are awesome, can you please explain monotonic stack/queue questions too ?

  • @ishankumarsethi8773
    @ishankumarsethi8773 4 ปีที่แล้ว

    Mam please explain more on two pointer approach in your next videos.

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว

      For sure! Going to make a video on this!

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

    0:00 to 0:02:
    Is that a way to say Hi using the sliding window approach? 😂

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

    Time Complexity of Naive approach should be O(N-K)*K

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

    NIce

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

    Aapko react aati h kya?

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

    Your explanation reminds me of aditya verma :)

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว +1

      That's a compliment!!
      He has another level fan following 😊

  • @shrenikpatodi4854
    @shrenikpatodi4854 4 ปีที่แล้ว +1

    👍

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

    Didi aap bhi Adithya Verma bhayya ki tarah yek concept ko pakdo aur Usko detail me samjhado
    Koi notice kia hai kya Adithya Verma bhayya ki channel ke subscribers tho another level pe increase ho rahe hain
    Aur subscribers chahte hon to aap ka bhi kaam nikal jaayega

  • @theexposerprint7574
    @theexposerprint7574 4 ปีที่แล้ว

    this code seems incorrect to me.

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว +1

      Hi, how is that? Could you please share more?

    • @theexposerprint7574
      @theexposerprint7574 4 ปีที่แล้ว

      @@KeertiPurswani it's fine. you explained it very well.

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว +1

      @@theexposerprint7574 thanks 🙂

    • @theexposerprint7574
      @theexposerprint7574 4 ปีที่แล้ว

      @@KeertiPurswani going to watch all of your videos. will let you know if i find any issue.

    • @KeertiPurswani
      @KeertiPurswani  4 ปีที่แล้ว

      @@theexposerprint7574 awesome 😇🙂

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

    better than most of the trash on Yt

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

    This didn't turn out that well

  • @santoshjaishi3
    @santoshjaishi3 4 ปีที่แล้ว

    Tumme bahut jyada adss lagaya he.

  • @prototypebharrat
    @prototypebharrat 5 หลายเดือนก่อน

    Out of topic but You have changed so much after marriage

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

    Nice explanation mam ....you explained it from the scratch itself ,this is the first video I am watching in this channel and am impressed and subscribed as well... keep doing on this topics