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

Sdílet
Vložit
  • čas přidán 26. 07. 2024
  • The video includes following details-
    0:00-1:00 - Introduction
    1:00-2:12 - Question with Brute Force Approach
    2:12-6:52 - Concept with example
    6:52-10:28 - Code
    10:28-11:36 - Why is it Dynamic Programming
    11:36-13:40 - How to Identify Questions
    13:40-14:45 - Dynamic Length Window cases
    14:45-15:17 - Two pointer technique
    15:17-16:15 - Variations of questions
    16:15-16:28 - Thank you!
    Please Subscribe to my channel - / keertipurswani
    LinkedIn - / keertipurswani
    Instagram - keerti.purs...

Komentáře • 106

  • @saiyashwanth1991
    @saiyashwanth1991 Před 3 lety +14

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

  • @zmxncbv95
    @zmxncbv95 Před 2 lety

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

  • @matrixRule127
    @matrixRule127 Před 3 lety +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! 😍

  • @ankitranjan88
    @ankitranjan88 Před 2 lety +1

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

  • @TUSHARSHARMA-zr1fc
    @TUSHARSHARMA-zr1fc Před 2 lety

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

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

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

  • @osvaldocarrillo1361
    @osvaldocarrillo1361 Před 2 lety

    Awesome, thank you!

  • @krrishiyer1016
    @krrishiyer1016 Před 3 lety

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

  • @tombrady7390
    @tombrady7390 Před 3 lety

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

  • @suryakantchavan7061
    @suryakantchavan7061 Před 3 lety +2

    Thank you nice one

  • @vigneshhendrix4447
    @vigneshhendrix4447 Před 3 lety +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!😂🔥

  • @pranjalsingh1287
    @pranjalsingh1287 Před 3 lety +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 Před rokem

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

  • @sprajwal-lq3zz
    @sprajwal-lq3zz Před 11 měsíci

    great explanation thanks.

  • @aryankhurana1847
    @aryankhurana1847 Před 3 lety

    Awesome!

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

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

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

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

  • @urrahman196
    @urrahman196 Před 2 lety +2

    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] .

  • @ayanroy8757
    @ayanroy8757 Před 2 lety

    best video on window sliding

  • @CSharpProdigy
    @CSharpProdigy Před 2 lety +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..

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

    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

  • @prasadm3614
    @prasadm3614 Před rokem

    M super glad that this video is in English !

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

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

  • @debaduttapanda7816
    @debaduttapanda7816 Před 2 lety

    really helpful

  • @ashutoshkumar4267
    @ashutoshkumar4267 Před 3 lety

    Great explaination, Thanks

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

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

  • @sreekanthjanapati409
    @sreekanthjanapati409 Před 2 lety

    Nice explanation

  • @pranavsingh1081
    @pranavsingh1081 Před 2 lety

    Very good explanation

  • @AritraBhattacharyya91
    @AritraBhattacharyya91 Před 3 lety

    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).

  • @deeyasings
    @deeyasings Před rokem

    Helpful

  • @harshitakanal7411
    @harshitakanal7411 Před 3 lety

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

    • @KeertiPurswani
      @KeertiPurswani  Před 3 lety

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

  • @ishaankulkarni49
    @ishaankulkarni49 Před 2 lety

    very helpful!

  • @haripriyaveluchamy9449

    mam ur explanation is too good

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

    One of the most underrated channel fr

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

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

  • @rudraksh9635
    @rudraksh9635 Před 3 lety

    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  Před 3 lety

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

    • @rudraksh9635
      @rudraksh9635 Před 3 lety

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

    • @akshayar2383
      @akshayar2383 Před 2 lety

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

  • @arukshasilvie
    @arukshasilvie Před 2 lety

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

  • @divakarr6743
    @divakarr6743 Před 2 lety

    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?

  • @vivekjaiswar6825
    @vivekjaiswar6825 Před 2 lety +2

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

  • @hiteshgupta219
    @hiteshgupta219 Před 3 lety +2

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

  • @priyachauhan813
    @priyachauhan813 Před 2 lety

    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)

  • @rydham8252
    @rydham8252 Před 3 lety

    Very well explained topic 👍👍.

  • @jatinmalhotra2117
    @jatinmalhotra2117 Před 3 lety

    very good explanation ! 👍

  • @tejaswi4650
    @tejaswi4650 Před 3 lety

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

  • @FinanceMode14
    @FinanceMode14 Před 2 lety

    NIce

  • @sonupunia
    @sonupunia Před 3 lety

    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  Před 3 lety

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

  • @VinodMuda
    @VinodMuda Před 2 lety

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

  • @pawanagrawal7653
    @pawanagrawal7653 Před 3 lety

    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.

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

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

  • @chiranshuadik9818
    @chiranshuadik9818 Před 2 lety

    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?

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

    👍

  • @ermahesh2009
    @ermahesh2009 Před 9 měsíci

    any real use case?

  • @aadarsh8839
    @aadarsh8839 Před 2 lety

    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

  • @pokiripkr
    @pokiripkr Před 3 lety

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

  • @suyashmisra7406
    @suyashmisra7406 Před 3 lety

    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!

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

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

  • @himanshugupta7010
    @himanshugupta7010 Před 2 lety

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

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

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

    • @kurmasaideep4072
      @kurmasaideep4072 Před 2 lety

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

  • @bhanuchirutha
    @bhanuchirutha Před 3 lety

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

  • @ishankumarsethi8773
    @ishankumarsethi8773 Před 3 lety

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

  • @vjkumk
    @vjkumk Před 2 lety

    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 Před 2 lety

    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.

  • @aayush5474
    @aayush5474 Před 3 lety

    Your explanation reminds me of aditya verma :)

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

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

  • @AgAnushree
    @AgAnushree Před 2 lety +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]

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

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

  • @vishalmittalvishalmittal

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

  • @rakshithd4942
    @rakshithd4942 Před 2 lety +1

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

  • @silverbullet_6
    @silverbullet_6 Před 2 lety

    better than most of the trash on Yt

  • @shaikfahim1232
    @shaikfahim1232 Před 3 lety

    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

  • @LeadCode1
    @LeadCode1 Před 3 lety

    Aapko react aati h kya?

  • @amolmohadikar6716
    @amolmohadikar6716 Před rokem +1

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

  • @theexposerprint7574
    @theexposerprint7574 Před 3 lety

    this code seems incorrect to me.

  • @MsBlueshark
    @MsBlueshark Před 9 měsíci

    This didn't turn out that well

  • @santoshjaishi3
    @santoshjaishi3 Před 3 lety

    Tumme bahut jyada adss lagaya he.

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

    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