JavaScript Sliding Window Technique - Fixed Size

Поделиться
HTML-код
  • Опубликовано: 20 авг 2024
  • The Sliding Window technique - a classic technique for solving many algorithm challenges involving subarrays and substrings. With the sliding window technique, we can achieve a linear runtime complexity of O(n). In particular, I demonstrate the fixed variant of the sliding window technique using JavaScript. Created by Gregg Fine.
    Download my FREE "Google Search Secrets for Developers" Cheat Sheet:
    store.thecodec...
    🗣JOIN the Code Creative Facebook group! :
    / 1612600368887577
    🔴Subscribe for more free Code Creative videos: : / @thecodecreative
    🌐 The Code Creative Official Website
    www.thecodecre...
    🎓 The Code Creative Courses
    www.thecodecre...
    ✅ Recommended related videos:
    Debouncing Explained
    • Debouncing Explained |...
    Memoization Explained
    • JavaScript Memoization...
    Sorting in JavaScript Explained
    • JavaScript Comparator ...
    ✅ For business inquiries contact me at gregg@greggfinedev.com
    ✅ Let's connect:
    Twitter - @GreggFine
    Instagram - /greggfinedev
    Facebook - /hiddentigermusic

Комментарии • 84

  • @TheCodeCreative
    @TheCodeCreative  4 года назад

    To subscribe to the channel: ruclips.net/channel/UCmOpHGj4JRWCdXhllVTZCVw

    • @handsanitizer2457
      @handsanitizer2457 3 года назад +1

      Just found you, this is 👍 thanks for the video

    • @TheCodeCreative
      @TheCodeCreative  3 года назад

      @@handsanitizer2457 Great, thanks for watching!

  • @paschalynukwuani6930
    @paschalynukwuani6930 Год назад +6

    This is undoubtedly the best explanation for a tutorial on algorithms I have seen on RUclips. I look forward to receiving more notifications to watch more tutorials from this channel. You are amazing with your way of explanation. Thank you!

  • @johnnewman8865
    @johnnewman8865 4 месяца назад +2

    I've researched good explanation for this technique. Your version is the best. Thanks for your videos.

  • @batmunkhn6666
    @batmunkhn6666 2 года назад +1

    this is the best way someone explained the technique and the actual code

  • @CakeBossan
    @CakeBossan 5 месяцев назад

    the brute force approach is not quadratic, but it is O(nm), where m is the fixed window size and n is the number of elements in the array. If you assume that m

    • @CakeBossan
      @CakeBossan 5 месяцев назад

      even when m is close to n, it is not quadratic as the number of iterations drops significantly, so it is closer to linear time.

  • @okonkwo.ify18
    @okonkwo.ify18 2 года назад +1

    Videos are better for learning than reading online. I have read and read about this and couldn’t understand anything. But your video makes it clear to me

  • @dumtoimoh2840
    @dumtoimoh2840 8 месяцев назад +1

    first time i saw sliding window it looked like a hard code to understand, but bro you just demystified it

  • @losbur5416
    @losbur5416 3 года назад +1

    The way you explain this algorithm is just incredible

  • @dheerajnaik6467
    @dheerajnaik6467 4 года назад +3

    Hi sir .. these algorithms and the way you explain them are amazing . please don't stop .. these are the best in youtube.

    • @TheCodeCreative
      @TheCodeCreative  4 года назад

      Hi Dheeraj, thanks for the kind words. More videos coming soon. Thanks for watching!

  • @ryanbollettino8983
    @ryanbollettino8983 2 года назад +1

    Thank you for this. Been struggling to grasp the concept of coding it.
    The "aha" was when I realized that [i] will ALWAYS be bigger than [size -1] once you have your first "true" sum of numbers.
    Subscribed and watching. Thanks again!

  • @starvisor751
    @starvisor751 2 года назад +1

    You explained this so eloquently and now I have a clear understanding of this method. Thank you.

  • @aslan6921
    @aslan6921 Год назад +1

    Best algorithm explanation that i ever found!

  • @TheCodeCreative
    @TheCodeCreative  4 года назад

    🗣JOIN the Code Creative Facebook group! :
    facebook.com/groups/1612600368887577

  • @tripl9111
    @tripl9111 2 года назад +2

    wow! This is the best video on the sliding window pattern. Your explanation is top notch and animations and audio quality are outstanding. Please do more videos on other patterns like Two Pointers and Fast and Slow pointers. Keep up the great work!

  • @prasannakumari1597
    @prasannakumari1597 Год назад +1

    Excellent Explanation Sir. Thank you very much.

  • @wabbit2158
    @wabbit2158 Год назад +1

    golden content, needs to be at 1 million+ views really...

  • @TheCodeCreative
    @TheCodeCreative  2 года назад

    📖 Download my FREE "Google Search Secrets for Developers" Cheat Sheet:
    store.thecodecreative.com/google-secrets-cheat-sheet

  • @nemanjam6272
    @nemanjam6272 Год назад +1

    You the man. Thank you

  • @yokohibarashi1386
    @yokohibarashi1386 3 года назад +1

    Your voice and the calm clear explanation really helped me understand this technique. Subscribed and liked!

    • @TheCodeCreative
      @TheCodeCreative  3 года назад

      That's great to hear! Thanks for watching 👍🏻

  • @todaysmotivation9692
    @todaysmotivation9692 2 года назад +1

    The video presentation and transition of the window over array and you method was awsome

  • @aysesinanmuslu7409
    @aysesinanmuslu7409 3 года назад +1

    I loled at 4:05 Nice videos!

  • @oaklandathleticfan12
    @oaklandathleticfan12 2 месяца назад +1

    Amazing video, thank you

  • @gboyegalawal8881
    @gboyegalawal8881 2 года назад +1

    This is really helpful. Thank you

  • @alexandernemechek3494
    @alexandernemechek3494 2 года назад +1

    Excellent video!

  • @muriukialex
    @muriukialex Год назад +1

    Thank you mate!

  • @Human_Evolution-
    @Human_Evolution- 2 года назад +1

    love the MDN screenshots and the voice is great. Subbed.

  • @subhashgn1775
    @subhashgn1775 2 года назад +1

    Enjoyed your teaching.
    Very grateful to you man...

  • @jamjam3448
    @jamjam3448 2 года назад +2

    Wowww. Thanks a million 😁 😁 😁

  • @vinothkannans1910
    @vinothkannans1910 3 года назад +1

    Great explanation with Clarity 👍

  • @showwong4466
    @showwong4466 3 года назад +1

    Excellent explanation! Thank you.

  • @aryanisml
    @aryanisml Год назад +1

    Good Explanation

  • @DharmikGohil-bw2ug
    @DharmikGohil-bw2ug 3 года назад +1

    keep it up 👌👌👌 great videos with great values thanks i hope your channel grow fast

  • @LazyShady
    @LazyShady 2 года назад +1

    Good explaination.

  • @arunkaiser
    @arunkaiser 3 года назад +1

    Awesome Greg 👍🏽👍🏽👍🏽

  • @JaBoss397
    @JaBoss397 2 года назад +1

    THANK YOU KEEP UP GOOD WORK I WAS STRUGGLING WITH SLIDING WINDOWS. Do you have a dynamic sliding window video ????

    • @TheCodeCreative
      @TheCodeCreative  2 года назад

      Thanks! No dynamic sliding window yet, but stay tuned!

  • @Eeezus1914
    @Eeezus1914 3 года назад +1

    great explanation

  • @zameeebasha
    @zameeebasha 4 года назад +1

    Awesome!

  • @oluwatobioyewole1501
    @oluwatobioyewole1501 3 года назад

    Hi, thanks so much for the clear explanation found it very insightful.
    I would like to know other algorithmic techniques one should know because this is my first time hearing about this concept. Hence, am very curious about other concepts like the sliding window technique

  • @linas3075
    @linas3075 2 года назад

    First of all, thank you for the tutorial! It's very well-paced and easy to follow.
    However, I have a question regarding subtracting the number once i gets to >= size. On line 9, we do this:
    `currSum -= nums[i - (size-1)];`
    Is it correct, though? Let's say, our i is 3, which means that we have to "move" the window, remove the first element and start calculating from the second element in the array. In that case, we should subtract nums[0], which is nums[i - size] (= nums[3-3]). If we subtract nums[3 - (3-1)], we end up subtracting nums[1], which is incorrect, isn't it?

  • @patrickchan2503
    @patrickchan2503 3 года назад

    thanks for this, would be good to do a nested for loop so we could compare it with the optimised solution, just a thought, thanks.

  • @cvain07
    @cvain07 3 года назад +1

    please bring a dsa algoritm interview prep series in js

  • @potterfreak63
    @potterfreak63 2 года назад +1

    anyone else here for advent of code?

  • @cmdv42
    @cmdv42 Год назад +1

    💯✨

  • @_slier
    @_slier 3 года назад +1

    i guess the cat have a hard time understanding the sliding window algos.

  • @greggfineguitar
    @greggfineguitar 4 года назад

    🗣JOIN the Code Creative Facebook group! :
    facebook.com/groups/1612600368887577