Sliding Window Technique - Algorithmic Mental Models

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ •

  • @omkarpat
    @omkarpat 5 років тому +612

    One of the best explanations of this concept. Please make some more "Algorithmic Mental Models" based videos.

    • @CEOofTheHood
      @CEOofTheHood 4 роки тому +24

      dude u seriously need to make more of these. Ill pay for them.

    • @andrewblaines
      @andrewblaines 4 роки тому +17

      Agreed! These are great. More "Algorithmic Mental Models" for dynamic programming, backtracking, etc. would be extremely helpful.
      Thanks for the video!

    • @veliea5160
      @veliea5160 4 роки тому +9

      it is not one of the best, it is the best

    • @Mogwai88
      @Mogwai88 3 роки тому

      @@CEOofTheHood Yes. Please make more of these. Especially with your new freecodecamp traffic this would really take off.

    • @AhmadRafique-yn8ry
      @AhmadRafique-yn8ry 4 місяці тому

      Agreed

  • @jacktrainer4387
    @jacktrainer4387 4 роки тому +197

    I've never before seen a CS video that approached CS like math (i.e., here are the concepts, here are some keywords to look out for so you know when to apply these concepts, here are a few examples). The world needs 1,000 more videos like this (DP, Linked Lists, Trees, Graphs, etc). Fantastic work!

  • @brijeshhota550
    @brijeshhota550 Місяць тому +1

    I knew about Sliding Window but never fully understood the pattern of questions to target or saw it visually represented so well and simply. You should definitely consider doing a playlist of these patterns, super intuitive.

  • @maggiesayabie
    @maggiesayabie 4 роки тому +16

    Who even has the audacity to dislike such a video?? The best and simplest explanation of sliding window concept i have ever come across. Thank you sir!

    • @priyamrai5915
      @priyamrai5915 10 місяців тому +1

      will it work if array has negative elements. I think no.

  • @vicente3j
    @vicente3j 2 роки тому +2

    Only 219k views... no way. This is by far some of the best CS-related content on UA-cam, hands down. Amazing!!

  • @fahadhayat_
    @fahadhayat_ 3 роки тому +20

    Dude please create a playlist for the other techniques as well!!! This is gold!

    • @zappist751
      @zappist751 Рік тому +1

      Does he have a playlist for this?

  • @pjmiravalle
    @pjmiravalle 2 роки тому +7

    I came across this video after struggling with sliding window problems in preparation for my upcoming Google interview, and just wanted to thank you for the super clear explanation. I'm feeling much more confident with these problems now. 👍

    • @tomrobinson8290
      @tomrobinson8290 2 роки тому +2

      Did you get into google? How was the interview!?

  • @maxdrojjin6984
    @maxdrojjin6984 5 років тому +84

    This is really the best video (or any, really) explanation of the topic I have found. Really hope this would become more popular. Thank you!

  • @weijinghuang8518
    @weijinghuang8518 3 роки тому +1

    This is the best video I've ever seen on this topic "sliding window"! It does not only solve one or two interview questions for me but also solves a group of problems. More than that, it teaches me how to spot this group of problems. Fantastic!!!

  • @parthabhowmik4747
    @parthabhowmik4747 2 роки тому +2

    The best lecture on sliding window technique

  • @shriduttkothari
    @shriduttkothari 3 роки тому +4

    This is the only video which made me understand dynamic window sizing algorithm... Thank you so much 🥰

  • @sedgeralt
    @sedgeralt 2 роки тому +2

    Hands down the best explanation of the Sliding Window technique. Please do more algorithmic mental model videos!

  • @syedaffanhameed14
    @syedaffanhameed14 3 роки тому +1

    I found "Algorithmic mental models" is a great concept for solving problems please bring more videos like this.

  • @codesefod8527
    @codesefod8527 2 роки тому

    1. Liked 2. Subscribed 3. Notifications Turned On. Please keep posting, one of best the best explanations for sliding window problems. Thank You Ryan!

  • @sujityadawad
    @sujityadawad 5 років тому +12

    Was struggling a lot with sliding window problems earlier, your explanation really simplified those problems. I really appreciate your effort. Thank you! Please post more videos.

  • @omaryahia
    @omaryahia 2 роки тому

    a simple visual explanation,
    detailed, with variants
    this is amazing, thank you

  • @TheN8H
    @TheN8H 8 місяців тому

    I've really struggled visualizing this algorithm concept and this video is extremely intuitive and detailed. Would love to have more of these videos.

  • @SauravTiru
    @SauravTiru 4 місяці тому

    Learning from you to for my job hunt in Zurich, I shall get back to this video once I get my job ! Thanks in advance for everything!

  • @rafaeldietrich8050
    @rafaeldietrich8050 2 роки тому

    This is probably hands down the best explanation of the Sliding Window technique i've seen. Great job!

  • @dr_920
    @dr_920 5 років тому +9

    One of the best tutorials I have even seen. Thanks.

  • @francksgenlecroyant
    @francksgenlecroyant Рік тому

    Thank you @Ryan Schachte for clarifying the sliding window technique and make it so simple just like that.
    I hope you upload a lot more vids like this bro !

  • @TheDev05
    @TheDev05 3 роки тому +1

    The animation for second technique: dynamic SW is just awesome, I loved it

  • @nan5715
    @nan5715 8 місяців тому

    I like that you actually name your variables in a meaningful way. 👍

  • @pbard42
    @pbard42 2 роки тому

    Wow great explanation, love the ‘teach a man to fish’ approach to the algorithm problems!

  • @peacebakare
    @peacebakare 2 роки тому

    This is the best explanation on Sliding Window I have seen so far. Thank you for the detailed yet simple approach to explaining the concept.

  • @cse9003
    @cse9003 4 місяці тому

    why suddenly when i graduated all these channels poped up when i needed them the most , bro you are the best

  • @abduuhany
    @abduuhany 6 місяців тому

    I love the idea of "Algorithmic Mental Models"! Thank you so much for explaining this perfectly and I'd love to see more videos for this idea!

  • @thatChillLife2037
    @thatChillLife2037 7 місяців тому

    dude I am only 2 minutes in and I've liked and subscribed! Between the visuals and your consice explanations, the sliding window technique (which I never thought I'd understand) makes SO MUCH SENSE! Thanks so much :)

  • @silvahawk
    @silvahawk 3 роки тому +5

    I have always been calculating the first windowSum in a separate loop before starting to "move" the window in a separate loop. I never knew you could do both within the same loop without using a nested loop. This is amazing!

  • @neerajkulkarni6506
    @neerajkulkarni6506 4 роки тому +7

    This is fantastic! Please make more of these 'mental model' videos. There too many videos out there that jump straight to the solution without any discussion of how to approach and generalize a problem. We need more video's like this!

  • @yasirayaz7832
    @yasirayaz7832 2 роки тому

    Nice explanation. I am glad I landed here while searching for all possible solutions for solving the array problems

  • @igcmjoeabar8475
    @igcmjoeabar8475 3 роки тому

    Guys, seriously, just study this video! It will help tremendously!!!
    Thanks for such helpful content

  • @brenoaps
    @brenoaps 8 місяців тому

    A series of algorithmic mental models would be awesome, great work!

  • @ibrahimhegazi3955
    @ibrahimhegazi3955 5 місяців тому

    You might be a professor or a normal student, but your explanation skills are exceptional. Add to that most of the videos explaining algorithms do not include such an amazing visualization for the data structures that we are working with. I hope one day you will have the free time to make a full algorithms and data structures for competitive programming course with such an amazing visualization. Hope you the best sir whereever you are.

  • @billyfigueroa1617
    @billyfigueroa1617 10 місяців тому

    What an excellent, well paced, well explained video with explaining the theory but also showing it in examples
    THANK YOU!
    The more you research the more you come to understand that trying to solve all these problems individually with out knowing about techniques like these, is so painful lol

  • @shrey4489
    @shrey4489 2 роки тому +3

    Great explanation! I'm a visual learner and I can see myself imagining these sliding window animations when I face array problems like this in the future.

  • @svdfxd
    @svdfxd 5 років тому +7

    One of the The best videos to explain Sliding windows concept. Request you to make other such videos that will help in tech interviews.

  • @akhalil3482
    @akhalil3482 3 роки тому +1

    we need more of this series! please do more!

  • @Finn-jp6pn
    @Finn-jp6pn 4 роки тому +1

    Would love more of these 'Algorithmic Mental Models' videos. I'm sure everyone here would appreciate them.

    • @Finn-jp6pn
      @Finn-jp6pn 4 роки тому

      @maryam I'm sure there are more capable people here who can help you. I don't have much experience with Python.

  • @for461
    @for461 6 місяців тому

    you are a very good teacher in layman language you are reaching. We will surely crack interviews with these

  • @billycheung7095
    @billycheung7095 2 роки тому

    Thanks you with tear. You constructed a solid framework for handling sliding window in my head.

  • @back2bits
    @back2bits 11 місяців тому

    This is -by far- the best video on this topic I have seen. Thanks for taking the time to produce such a great content. Keep it up!

  • @ShivamJha00
    @ShivamJha00 Рік тому

    After watching this one, I could solve even the hard LC problems within 15-20 mins. This is a gem of a video on this topic. Hope you make more of these on other topics, I will literally pay for it

  • @frozen_tortus
    @frozen_tortus 4 роки тому +4

    I'm absolutelly blown away how this is explained.

  • @rahulkushwaha7742
    @rahulkushwaha7742 2 роки тому

    I struggled for longest substring problems and now here we are i solved it by my own after watching your video thanks buddy

  • @danielc4267
    @danielc4267 8 місяців тому

    31:11 The reason you "add 1" isn't because the array is indexed at 0. It's because the start element gets subtracted and it needs to be added back.
    Thank you for making the video :)

  • @amitrajitdas31
    @amitrajitdas31 3 роки тому

    One of the best explanation on YT

  • @for461
    @for461 6 місяців тому

    I am from India. THese are helping us cracking interview. THank you very much. Complicated topics you are making us understand very easily.

  • @debugquan
    @debugquan 2 роки тому

    Great guy. I was hesitant to watch the whole video but you were so informative that I actually learned something for many use cases. Thanks

  • @divyanirao4279
    @divyanirao4279 5 років тому +39

    This video is amazing. hope you make more videos on "mental models" such as for dynamic programming.

    • @michadobrzanski2194
      @michadobrzanski2194 3 роки тому

      Max subarray sum of k is also a dynamic programming problem. You reuse the previous max result and update it. So it is like dynamic programming with space complexity O(1).

  • @cocoarecords
    @cocoarecords 4 роки тому +1

    wow this deserve to be a series very underrated!

  • @pravinyadav8372
    @pravinyadav8372 3 роки тому

    This video gave the confidence that I'll mostly won't stuck in this topic anymore...Thank you : )

  • @MrAlmas01kz
    @MrAlmas01kz 2 роки тому +1

    One of the best and easy explanations of this concept. thank you so much !

  • @harshitmittal1217
    @harshitmittal1217 4 роки тому

    Literally the best explanation of sliding window technique.

  • @alonbrim
    @alonbrim 2 роки тому +1

    This video is pure gold!!! Great explanation . Everything is very clear. Thank you very much!

  • @uzvalmallepeddi8962
    @uzvalmallepeddi8962 3 роки тому +12

    I wouldn’t resist to pay a 1000$ to watch such videos. Brilliant piece of work! Hope you do more videos on “Mental models”

  • @alphapenguin9748
    @alphapenguin9748 4 роки тому +3

    Please make more algorithm videos, you're literally the best explainer I have found on youtube.

  • @vincenthou6459
    @vincenthou6459 2 роки тому +1

    This is such an awesome video by abstracting the idea of sliding window to tackle a group of specific issues with similarities. Regarding the question of smallest subarray for a given target, I think we need to add the constraint that every element in the array is positive. Otherwise, the sum can be reduced even if we grow the size of the window without dropping the front one. 28:37

  • @sivanyaniv64
    @sivanyaniv64 2 роки тому

    this is the best video I was watching about sliding window - thank you !!

  • @danielderese3170
    @danielderese3170 2 роки тому

    I can't thank you enough. I wish I have seen this video before I bombed in the Meta interview. Please make more videos on Algorithmic Mental Models!!!

  • @martinlacsamana7534
    @martinlacsamana7534 2 роки тому

    Only 13 minutes in but this is beautiful so far. Thank you.

  • @sarthakrege269
    @sarthakrege269 4 роки тому

    This is the best video I have ever seen on an algorithmic topic!! Please make more content like this!! Love the idea of the algorithmic mental model! :))

  • @WhosShamouz
    @WhosShamouz 2 роки тому

    Rewatched some parts of it. Perfect, breathtaking. The best tutorial ever.

  • @airysm
    @airysm 3 роки тому

    This video just came up in my recs as I'm interview prepping and I'm so mad this is your only video like it! I thought I hit a goldmine for interview prep for a sec LOL, but nonetheless this video is amazing. Thank you so much

  • @SushilDubey171
    @SushilDubey171 4 роки тому

    This is the best video for sliding window techniques

  • @plashless3406
    @plashless3406 2 роки тому

    This is amazing. I wish I could hug you for this best explainantion. I learned a lot.

  • @SantoshPrajapati-ps9nj
    @SantoshPrajapati-ps9nj 9 місяців тому +1

    This is the best explaination that i have came across 🙂

  • @mumarkhan1898
    @mumarkhan1898 2 роки тому

    In the second example 32:17 you're missing a condition in the inner while loop i.e windowStart should always be smaller or equal to windowEnd
    def get_smallest_sub_array_with_sum_greater_equal_to_a_value(a, k):
    left, right = 0, 0
    min_window_size = float('+inf')
    current_sum = 0
    while right < len(a):
    current_sum += a[right]
    while current_sum >= k and left

  • @Ore00000
    @Ore00000 3 роки тому

    I greatly appreciate the clear explanation of the dynamically resizable sliding window, it cleared up some doubts I have about the algorithm. Cheers!

  • @TechieIndia
    @TechieIndia 4 роки тому

    the best lecture available on any platform for SWT.
    I loved this video and your way of explanation.

  • @nehashimpi7643
    @nehashimpi7643 4 роки тому

    This is the best video I have seen!!Please please please make more videos on Algorithm Models!!

  • @potatocoder5090
    @potatocoder5090 2 роки тому +6

    I have struggled with this concept for a really long time, but not anymore :) Your explanations were absolutely beautiful and I'm excited to solve some sliding window problems now! Can you please create more Algorithmic Mental Model videos? We'd all be super grateful!

  • @waseemmn2007
    @waseemmn2007 9 місяців тому

    OMG, Best problem solving explanation I've ever seen.
    it is a really helpful, simple, and to the point, Thank you for this extraordinary video.
    Liked and subscribed 🙌

  • @pif5023
    @pif5023 10 місяців тому

    Nice video! Banger as a refresher for interviews.

  • @SheikhEddy
    @SheikhEddy 4 роки тому

    Please make more videos like this, it's one of the best things I've seen on youtube

  • @Sedri14
    @Sedri14 2 роки тому

    Best explanation so far. Thank you

  • @DonMamaril
    @DonMamaril 5 років тому +7

    I loved, looooved the format of this! Please continue to do these videos. Extremely helpful!!

  • @Maybec
    @Maybec 2 роки тому

    Thank you for your help. Please add more videos to the algorithmic mental models series. please and thank you!

  • @wittyhumour29
    @wittyhumour29 3 роки тому

    Amazing explanation of the Sliding-Window Technique. Would love to see more of Algorithmic Mental Models.

  •  Рік тому +1

    Thanks, I flew through LeetCode Sliding Window challenges after watching this.

  • @jude3926
    @jude3926 2 роки тому

    I need more of this!! You just earned yourself a subscriber

  • @Shiva-zy7jq
    @Shiva-zy7jq 4 роки тому

    Best video on youtube about sliding window technique. Thank you so much.

  • @davidodia4603
    @davidodia4603 3 роки тому

    Incredibly simple explanation. I felt like a baby being handed his lego building blocks. I absolutely learnt a hitherto abstract concept, i will never forget.

  • @CantBeTamed53
    @CantBeTamed53 2 роки тому

    Great use of graphics to explain the algorithm! :D

  • @shuvbhowmickbestin
    @shuvbhowmickbestin 2 роки тому +1

    what a comprehensive video! Learnt a lot, liked and subbed. Keep bringing new content, you teach really good!

  • @GoblinBlaster3000
    @GoblinBlaster3000 2 роки тому

    Great explanation, didn't know anything about sliding window before this video and I got enough information where I could implement it no problem.

  • @giampierovanzzini1430
    @giampierovanzzini1430 2 місяці тому

    This is a really great informative video, thanks for the hard work! I really like the breakdown to creating a mental model

  • @dolicious
    @dolicious 3 роки тому +1

    this was such a good explanation !! I hate Java but through your explanation I was able to understand what each line of code was doing. Even pointing out certain words that give away how one should solve the problem. Looking forward to future algo breakdowns !

    • @alivation3409
      @alivation3409 2 роки тому

      Same! I know this is an old comment, but I was able to mentally translate this into the programming languages I do know algorithms in. This is a great video.

  • @B-Billy
    @B-Billy 10 місяців тому

    Hand down, the best explanation. Great work🎉 thank you❤

  • @muskulanikhil3623
    @muskulanikhil3623 Рік тому

    Fantastic, you should seriously consider doing dynamic programming series. Just 36 mins but got avery clear understanding of the topic

  • @yynnooot
    @yynnooot 2 роки тому +6

    Do you have a series for these Algorithmic Mental Models? Your video was extremely helpful and I would love to see more of these!

  • @williamahern6219
    @williamahern6219 2 роки тому

    This is an awesome, thorough explanation of the sliding window concept and is easy to follow!

  • @klaaskabini5407
    @klaaskabini5407 2 роки тому

    Best explanation so far. Please make more videos on algorithmns

  • @priyakumar6697
    @priyakumar6697 Рік тому

    Please make more of these! This was so helpful thank you.

  • @viralmehta2542
    @viralmehta2542 4 роки тому

    Great explanation for the problems! Code is concise!

  • @amreshgiri
    @amreshgiri 4 місяці тому

    🎯 Key points for quick navigation:
    00:09 *🧠 Sliding Window Technique Overview*
    - Overview of the sliding window technique as an algorithmic mental model,
    - Benefits of using sliding window over naive approaches,
    - Introduction to fixed size and dynamically resizing sliding window techniques.
    02:00 *🪟 Fixed Size Sliding Window Technique*
    - Explanation of fixed size sliding window using a rectangular metaphor,
    - Example of maximizing sum of a contiguous subarray using fixed size sliding window,
    - Comparison with brute-force approach highlighting efficiency gains.
    07:00 *📊 Identifying Sliding Window Problems*
    - Characteristics of problems suited for sliding window technique,
    - Common keywords and problem types (min/max, longest/shortest, containment),
    - Applicability across arrays, strings, and linked lists.
    13:38 *🎯 Types of Sliding Window Problems*
    - Fixed length variant: Example with fixed size subarrays and maximizing sums,
    - Dynamic resizing variant: Handling variable window sizes dynamically,
    - Dynamic variant with auxiliary data structures: Examples involving hash maps for advanced constraints like distinct characters.
    17:05 *🔄 Commonalities in Sliding Window Problems*
    - Sequential nature of problems and contiguous data groupings,
    - Criteria for solving problems (maximization, minimization, containment),
    - Unifying approach to algorithmic problem solving using sliding window technique.
    22:16 *📊 Sliding Window Technique for Fixed Window Size*
    - Explanation of the fixed-size sliding window technique,
    - Detailed walkthrough of how to maintain and update the sliding window,
    - Example problem solved using the fixed-size sliding window approach.
    24:58 *🎯 Dynamic Sliding Window for Variable Window Size*
    - Introduction to dynamic sliding window where window size can vary,
    - Problem-solving approach to find the smallest subarray with a given sum,
    - Demonstration of adjusting window size dynamically based on problem constraints.
    33:03 *🧩 Sliding Window with Auxiliary Data Structure*
    - Application of sliding window technique with an auxiliary data structure,
    - Problem-solving for finding the longest substring with K distinct characters,
    - Strategy for using hash maps to optimize tracking of character frequencies in the sliding window.
    Made with HARPA AI

  • @wintersol9921
    @wintersol9921 2 роки тому

    Thanks a lot, great explanation. I have been looking for UA-camrs like you all the time, good explanations with good content :D

  • @TaraChand-eg6uk
    @TaraChand-eg6uk 2 роки тому

    @Ryan : In case of smallestSubarray method, if targetSum is 9, it is failing, need to add another condition in it.
    private static int smallestSubarray(int targetSum, int[] input) {
    int currentWindowSum = 0;
    int minWindowSize = Integer.MAX_VALUE;
    int windowStart = 0;
    for (int windowEnd = 0; windowEnd < input.length; windowEnd++) {
    currentWindowSum += input[windowEnd];
    while (currentWindowSum >= targetSum && windowEnd > windowStart ) {
    minWindowSize = Math.min(minWindowSize, windowEnd - windowStart + 1);
    currentWindowSum -= input[windowStart];
    windowStart++;
    }
    }
    return minWindowSize;
    }

  • @tusharborole6155
    @tusharborole6155 5 років тому +1

    Best explanation so far

  • @arnobchowdhury9641
    @arnobchowdhury9641 4 роки тому

    Great explanation and thanks a lot. The way you visualized really helped to understand the concept.