L1. Introduction to Sliding Window and 2 Pointers | Templates | Patterns

Sdílet
Vložit
  • čas přidán 25. 03. 2024
  • Notes/Codes/Problem links under step 10 of A2Z DSA Course: takeuforward.org/strivers-a2z...
    Entire playlist: • Two Pointer and Slidin...
    Follow us on our other social media handles: linktr.ee/takeuforward

Komentáře • 156

  • @varun1017
    @varun1017 Před 3 měsíci +520

    Petition to Striver. We want strings.

  • @vect0r678
    @vect0r678 Před 2 měsíci +103

    Petition to Striver - We want string playlist ASAP!!

  • @harshsheth5545
    @harshsheth5545 Před měsícem +17

    31:28 One more big optimization is possible in the longest subarray solution.
    if (arr[r]>k) { r=r+1; l=r; sum=0}
    Here if a number itself is greater than 'k' then no subarray with that element can be a valid substring. So, we can move both left and right pointers to the next element (i.e. arr[r+1])

  • @rajatraj4297
    @rajatraj4297 Před 3 měsíci +37

    gurudev aaj ka leetcode daily dekh ke socha tha, striver ka sliding window kab aayega. aur aapne sun bhi li 😌

  • @user-of5fb6nb9e
    @user-of5fb6nb9e Před 3 měsíci +27

    Despite your busy schedule, you still manage to deliver invaluable content like this. I salute you, sir! Thank you very much for the teachings.

  • @sanskargupta2739
    @sanskargupta2739 Před 3 měsíci +92

    Petition to striver: we want string playlist

  • @angeldeveloper
    @angeldeveloper Před 3 měsíci +27

    Most awaited playlist🎉🎉🎉

  • @suryasaipalthi
    @suryasaipalthi Před 3 měsíci +6

    Man, this is really cool I am ngl I came across a sliding window sum today and was struggling today to do it, and here we are. Let's strive all the way. Thank you!

  • @thaman701
    @thaman701 Před 3 měsíci +28

    Striver bro---we want string palylist

  • @mansimishra7089
    @mansimishra7089 Před 3 měsíci +5

    This is something I was wishing 2 days back. Thanks Bhaiya :)

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

    Best intro of any series on CZcams 🎉

  • @tasneemayham974
    @tasneemayham974 Před 3 měsíci +4

    LONG AWAITEDDD SERIESS!!!
    THANK YOUUUUU STRIVERRRRRR SOO SOO OSOO MUCHHHHHH!!!!
    I am currently studying the graph series once I am done. I will jump to this one!!

  • @uditpanjiyar3203
    @uditpanjiyar3203 Před 3 měsíci +8

    today leetcode problem of the day is based on sliding window topic , and i am searching for the playlist of sliding window on youtube and you just launched complete playlist of S.W ammazzing you are great 🙏🙏

  • @nefarious001
    @nefarious001 Před měsícem +14

    VOTE FOR STRING PLAYLIST

  • @arnav7050
    @arnav7050 Před 3 měsíci +6

    Thumbnail upgrade crazyyy…thanx for your efforts….eagerly waiting for strings

  • @kunalwadhai777
    @kunalwadhai777 Před 3 měsíci +1

    Striver Bhaiya, I have just watched the introductory video of this playlist, and feels like it's a very cool explanation, I'm getting everything that you are saying for I am very grateful to you.

  • @atulwadhwa192
    @atulwadhwa192 Před 3 měsíci +1

    Most awaited series

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

    just saw this intro video and was able to solve the leetcode problem of the day (28th march) i am hyped up for this playlist!!

  • @tanvirahammed3783
    @tanvirahammed3783 Před 3 měsíci +20

    Hi Striver, I'm not sure if this comment will reach you or not, but I just want to say one thing: I've been watching your videos for more than a year now and have covered a huge part of the graph and dynamic programming playlists. Whenever I watch your videos, I really fall in love with your teaching style, and of course, your smile, and sometimes your small jokes. I enjoy your videos, and it feels like you're not just my tutor; it feels like you're someone very close to me, teaching me with fun and pleasure. However, in your recent playlists, I totally miss that. It feels like you're not as friendly anymore; you're just a teacher like any other tutor. Whenever I watch videos from this playlist, sometimes I wonder what happened to you. Why are you so quiet now? Why don't you joke around anymore? After all, I love your work; it's just my opinion.

  • @shwetanshusinha2690
    @shwetanshusinha2690 Před 3 měsíci +1

    Was waiting for this playlist from a long time. Thank u so much sir

  • @vishwaskalra8773
    @vishwaskalra8773 Před 3 měsíci +2

    Today i was thinking when will striver be teaching Sliding Window nd here it comes 🎉

  • @user-sp8ne7hj3n
    @user-sp8ne7hj3n Před 3 měsíci +2

    King is back with DSA..

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

    Awesome Bro! Great teaching skills!

  • @ParthKamal-iy9bf
    @ParthKamal-iy9bf Před měsícem

    you are doing great work striver

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

    Hey man, was waiting for this playlist for a long time. Appreciate your efforts

  • @omkharade9521
    @omkharade9521 Před 3 měsíci +3

    My motivation to continue grinding.

  • @srishtipandey6068
    @srishtipandey6068 Před 3 měsíci +57

    Please upload greedy and heaps playlist too #striver

    • @KartikeyTT
      @KartikeyTT Před 2 měsíci

      Greedy is coming next weekend

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

    Completed this amazing Video. Going to Blitz through every question/video now😈

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

    💯 / 10 teacher for dsa..

  • @monikayadav-wb6pu
    @monikayadav-wb6pu Před 3 měsíci

    Thank you so much ❤bhaiya apki sari videos kaffi helpful rahi hai hamare liye

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

    Tnq so much striver bhaiya...

  • @LinhHoang-ml1qo
    @LinhHoang-ml1qo Před měsícem

    thanks for your dedication !

  • @priyan8004
    @priyan8004 Před 2 měsíci

    Man ! you are amazing.

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

    Thanks for uploading 🙏

  • @a_13_balaji_k44
    @a_13_balaji_k44 Před 3 měsíci +3

    5:20 why no one is talking about the issue in the first problem , the first subarray isn't considered why? and no conditions given inside while loop why?
    Here is the Correct code
    int nums[] = new int[] {6,2,3,-1,-5,1,1};
    int k = 3;
    int left = 0;
    int right = 0;
    int sum = 0;
    int maxSum = Integer.MIN_VALUE;

    while(right

    • @sultan_3006
      @sultan_3006 Před 2 měsíci +1

      I was also wondering why no one has commented on that part!

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

      we will calculate the sum for the first subarray also and we later compare it with the upcoming subarrays sum . hope I made it clear

    • @purushottam108
      @purushottam108 Před 7 dny

      before going to loop we can put maxSum = sum it also work fine:
      #include
      using namespace std;
      int main(){
      int k = 2;
      vectorarr = {100,-2,1,-7,-1,10};
      int sum = 0;
      int maxsum = INT_MIN;
      for (int i = 0; i < arr.size(); i++)sum = sum + arr[i];
      int l = 0; int r = k-1;
      maxsum = sum;//so we dont miss the sum of first subarray
      while (r < arr.size()-1)
      {
      sum = sum - arr[l];
      l++;
      r++;
      sum = sum + arr[r];
      maxsum = max(maxsum,sum);
      }
      cout

  • @ibrahimlanre4285
    @ibrahimlanre4285 Před 3 měsíci +1

    bro striver i am so grateful for all you do ...but please a simple request on the heaps and string playlist🙏

  • @priyanshugagiya
    @priyanshugagiya Před 2 měsíci +1

    Optimization was so great 🥵 I never thought about improving 2n to n

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

    Thank You for the efforts

  • @user-of8ix7oq9t
    @user-of8ix7oq9t Před 21 dnem +1

    Hi, Thanks for the video first of all 😊, but at time 12:28, we can't break from the loop (as you did in else condition) as array can have negative elements further which will reduce sum and it can bring sum to less than or equal to k. That else condition is fine only when we don't have negative elements in the array.
    At 21:05, we don't need the if condition to check if sum

    • @aishwaryaanand5650
      @aishwaryaanand5650 Před 2 dny

      At 21:55, isn’t it important for the while loop to have one more condition i.e l

  • @xavier4107
    @xavier4107 Před 2 měsíci +1

    Petition to Striver: We want playlists on Strings & Prefix Sum logic, heap & updated playlist on hashing

  • @harshsheth5545
    @harshsheth5545 Před měsícem +3

    It is important to note that Pattern 2 is applicable for positive numbers only. In your case itself if the array was [2,5,1,7,-5,10] instead of [2,5,1,7,10] your solution would be wrong.

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

      can you explain how ?

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

      @@prasannasahoo0806 sure.
      During the execution when L is at position 0 and R is at position 3, the subarray 2,5,1,7 gives the sum 15 which is greater than 14 so L will move to position 1. The new sub array now is 5,1,7.
      Then R moves to position 4 but L does not move back to position 0. So, the subarray 2,1,5,7,-5 which is a valid array but it is not checked in this method.

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

    Thankyou so much Striver for all you efforts throughout in delivering us so much valuable content. Any student / working professional can now be able to transition their career without paying money for courses.
    Would also like your insights on the point :
    While preparing for interviews most of the aspirants are going through the videos solely and solving the question after completely watching the video. And also are feeling lazy trying to solve the question on our own. What is the best way to complete any topic without being lazy and how should an aspirant approach any topic/playlist?

  • @parthbhalerao3669
    @parthbhalerao3669 Před 2 měsíci +1

    Striver is god !!
    Thank you sir !!

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

    Thank you so much for this playlist sir 🙏🏻🫂❤️

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

    great work sir🙌

  • @dEviL_bIsWaJiT
    @dEviL_bIsWaJiT Před 2 měsíci

    Thanks a lot bhaiya 💙

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

    Finnally wait is over 😊

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 Před 23 dny

    NICE SUPER EXCELLENT MOTIVATED

  • @hat_awesome21
    @hat_awesome21 Před 3 měsíci +1

    Thanks a lot bro 🙏 ❤️

  • @devshubham5528
    @devshubham5528 Před 3 dny

    108k views and just 3.4k likes
    why people don't appreciate the creator. Always give it a like when you learned something from the video

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

    Really Helpful!

  • @t-anime517
    @t-anime517 Před 2 měsíci

    guru dev dhanyawad🙏

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

    wow finally 😍 . Thanks

  • @harshvardhansankpal716
    @harshvardhansankpal716 Před 3 měsíci +2

    5:38 in this problem the sum of first subarray is not being considered, plz store it in a separate variable and put in maxi( ) as well, or after finding the sum using for loop assign max_sum= sum; in that case we dont need an extra variable

  • @user-il9wr5du1y
    @user-il9wr5du1y Před 2 měsíci

    Amazing explanation, but one input from my side would be that before updating the window, we should check if(l

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

      i don't think so .. ig the first element is 15 then l++ will happen and r++ to so we will move to the second element and will create subarrays from there .

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

    Today i was thinking when will striver be teaching Sliding Window nd here it comes (2)

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

    Thanks for Sharing bhaiya !! Stack ka v upload kar divine !! ❤️🫠

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

    Thank u very much bhaiya

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

    Thank you very much

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

    awesome ❤

  • @Arya20012
    @Arya20012 Před 3 měsíci +1

    Thank you striver ❤, you are our hero

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

    bhaiya aaj ke contest me first time 3 question hua 🙂🙂🙂🙂because of you thank you

  • @ravigupta9784
    @ravigupta9784 Před 2 měsíci

    Thanks a lot🙂

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

    One playlist needed for greedy algo too.

  • @codeman3828
    @codeman3828 Před 2 měsíci

    Thanks. Understood

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

    understood bhaiya

  • @banothutharun2743
    @banothutharun2743 Před 2 měsíci

    superb bro

  • @Shivam-fl6uv
    @Shivam-fl6uv Před 3 měsíci

    Thank You

  • @user-tk2vg5jt3l
    @user-tk2vg5jt3l Před 2 měsíci

    Thank you bhaiya

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

    Samaj aa gaya.

  • @prajyot2021
    @prajyot2021 Před 10 dny

    thanks Raj

  • @kashafkhan9726
    @kashafkhan9726 Před 3 měsíci +1

    Was in waiting ✋️ list for this from a long time ⏲️.

  • @ok-jg9jb
    @ok-jg9jb Před 3 měsíci

    Thanks❤

  • @nayeemrafsan356
    @nayeemrafsan356 Před 2 měsíci

    this content is invaluable! can't thank you enough

  • @whatsyoursin
    @whatsyoursin Před 2 měsíci +2

    Those who agree we need strings playlist.

  • @Chai_parathe
    @Chai_parathe Před 3 měsíci +2

    Striver pls make string playlist 🥺

  • @impatientgaming9868
    @impatientgaming9868 Před 2 měsíci

    Great

  • @akashsoam7581
    @akashsoam7581 Před 3 měsíci +1

    we a similar small playlist for prefix sum

  • @NikhilKumar-xg7re
    @NikhilKumar-xg7re Před 3 měsíci

    Much needed playlist
    btw which app do you use for notes ?? what is the name of this app ??♥♥♥

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

    Done Sir😎

  • @anujkapri6054
    @anujkapri6054 Před 3 měsíci +4

    Can we have playlist on strings. Please

  • @aniketrangari8679
    @aniketrangari8679 Před 2 měsíci

    simplest way to learn

  • @thestarters9799
    @thestarters9799 Před 3 měsíci +1

    For else if(sum > k) break;
    There may be negative elements in array right?

  • @JohnJoe-pd9ph
    @JohnJoe-pd9ph Před měsícem

    Nice

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

    Thank you Sir! There was no playlist or videos regarding two pointers or sliding window on CZcams. Leetcode daily is asking problems related to it currently, would prove to be of great help.

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

      Check aditya verma sliding window playlist too bro

  • @RitikRaj-we2sc
    @RitikRaj-we2sc Před 3 měsíci

    Hey striver great video as usual.
    I wanted to ask about the update on intern position that you posted on linkedin. Have you started to review the assignments ?

  • @kanishkbairagi409
    @kanishkbairagi409 Před 2 měsíci

    Request to striver. We want strings playlists

  • @user-ym1nv1pw8i
    @user-ym1nv1pw8i Před 10 dny

    Revise optimal @30:00
    Understood!
    Mark for revision

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

    Understood.

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

    completed

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

    string algorithms ,suffix arrays

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

    LETS GOO...

  • @rishabhnema2479
    @rishabhnema2479 Před 3 měsíci +1

    Could you please add additional problems where instead of sum, product of subarrays pattern is taken.

  • @SanjeevM-yc5uj
    @SanjeevM-yc5uj Před 2 měsíci

    For the 3rd type where you find the number of subarrays satisfying the condition, can’t we just add an extra variable and check if the subarray is satisfying the equal condition and then increase the variable’s value accordingly. Like for example can’t we just include a variable called sub_array_count and then add 1 to it whenever sum = k inside the loop itself?

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

    ❤️

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

    petition to striver we want string playlist

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

    God is here... Ab koi bhi qn aa jaye sliding window ka contest mei🤝

  • @abhinavnarula7300
    @abhinavnarula7300 Před 3 měsíci +2

    I have a small doubt in the 2nd pattern's better approach, shouldn't we also check for l

    • @AjithKumaR-jw9wt
      @AjithKumaR-jw9wt Před 3 měsíci

      Yes, at the end we can put a condition if r less than l mean r equal to l plus one

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

    consistency 100

  • @iqube4636
    @iqube4636 Před 2 měsíci

    Will these work even if array consist of negative numbers?