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

Поделиться
HTML-код
  • Опубликовано: 25 мар 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

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

  • @varun1017
    @varun1017 3 месяца назад +551

    Petition to Striver. We want strings.

  • @vect0r678
    @vect0r678 3 месяца назад +113

    Petition to Striver - We want string playlist ASAP!!

  • @user-of5fb6nb9e
    @user-of5fb6nb9e 3 месяца назад +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.

  • @rajatraj4297
    @rajatraj4297 3 месяца назад +37

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

  • @harshsheth5545
    @harshsheth5545 2 месяца назад +18

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

    • @antor.morsalin
      @antor.morsalin 11 дней назад

      while optimizing, you kinda have to expect the input that is the most time consuming.

  • @angeldeveloper
    @angeldeveloper 3 месяца назад +27

    Most awaited playlist🎉🎉🎉

  • @nefarious001
    @nefarious001 Месяц назад +17

    VOTE FOR STRING PLAYLIST

  • @suryasaipalthi
    @suryasaipalthi 3 месяца назад +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!

  • @mansimishra7089
    @mansimishra7089 3 месяца назад +6

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

  • @tasneemayham974
    @tasneemayham974 3 месяца назад +5

    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 3 месяца назад +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 🙏🙏

  • @arnav7050
    @arnav7050 3 месяца назад +6

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

  • @kunalwadhai777
    @kunalwadhai777 3 месяца назад +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.

  • @thaman701
    @thaman701 3 месяца назад +29

    Striver bro---we want string palylist

  • @abhay3545
    @abhay3545 3 месяца назад

    Best intro of any series on RUclips 🎉

  • @sanskargupta2739
    @sanskargupta2739 3 месяца назад +98

    Petition to striver: we want string playlist

  • @tanvirahammed3783
    @tanvirahammed3783 3 месяца назад +21

    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.

  • @atulwadhwa192
    @atulwadhwa192 3 месяца назад +1

    Most awaited series

  • @shwetanshusinha2690
    @shwetanshusinha2690 3 месяца назад +1

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

  • @vishwaskalra8773
    @vishwaskalra8773 3 месяца назад +2

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

  • @ropurifiedwater
    @ropurifiedwater 3 месяца назад

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

  • @franciskp9117
    @franciskp9117 3 месяца назад

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

  • @user-sp8ne7hj3n
    @user-sp8ne7hj3n 3 месяца назад +2

    King is back with DSA..

  • @omkharade9521
    @omkharade9521 3 месяца назад +3

    My motivation to continue grinding.

  • @a_13_balaji_k44
    @a_13_balaji_k44 3 месяца назад +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 3 месяца назад +1

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

    • @prasannasahoo0806
      @prasannasahoo0806 2 месяца назад

      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 19 дней назад

      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

  • @ParthKamal-iy9bf
    @ParthKamal-iy9bf Месяц назад

    you are doing great work striver

  • @aishwarya156
    @aishwarya156 3 месяца назад

    Awesome Bro! Great teaching skills!

  • @blitztour5924
    @blitztour5924 3 месяца назад

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

  • @srishtipandey6068
    @srishtipandey6068 3 месяца назад +57

    Please upload greedy and heaps playlist too #striver

    • @KartikeyTT
      @KartikeyTT 3 месяца назад

      Greedy is coming next weekend

  • @monikayadav-wb6pu
    @monikayadav-wb6pu 3 месяца назад

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

  • @dracoadi6239
    @dracoadi6239 6 дней назад

    best concept explanation so far

  • @ibrahimlanre4285
    @ibrahimlanre4285 3 месяца назад +1

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

  • @survivourff7014
    @survivourff7014 3 месяца назад

    Tnq so much striver bhaiya...

  • @user-vs8xp2kk4b
    @user-vs8xp2kk4b 3 месяца назад

    💯 / 10 teacher for dsa..

  • @LinhHoang-ml1qo
    @LinhHoang-ml1qo 2 месяца назад

    thanks for your dedication !

  • @Cool96267
    @Cool96267 Месяц назад

    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?

  • @priyan8004
    @priyan8004 2 месяца назад

    Man ! you are amazing.

  • @user-zk4og6sy1d
    @user-zk4og6sy1d 3 месяца назад

    Thanks for uploading 🙏

  • @ritikanand3425
    @ritikanand3425 3 месяца назад

    Thank You for the efforts

  • @user-of8ix7oq9t
    @user-of8ix7oq9t Месяц назад +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 14 дней назад

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

  • @harshsheth5545
    @harshsheth5545 2 месяца назад +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 2 месяца назад

      can you explain how ?

    • @harshsheth5545
      @harshsheth5545 2 месяца назад

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

  • @manikantareddy9454
    @manikantareddy9454 Месяц назад

    great work sir🙌

  • @priyanshugagiya
    @priyanshugagiya 3 месяца назад +1

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

  • @hat_awesome21
    @hat_awesome21 3 месяца назад +1

    Thanks a lot bro 🙏 ❤️

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 Месяц назад

    NICE SUPER EXCELLENT MOTIVATED

  • @user-rk2vo5zb3e
    @user-rk2vo5zb3e 3 месяца назад

    Really Helpful!

  • @JohnWickea
    @JohnWickea 3 месяца назад

    wow finally 😍 . Thanks

  • @dEviL_bIsWaJiT
    @dEviL_bIsWaJiT 3 месяца назад

    Thanks a lot bhaiya 💙

  • @shivanshmahajan2281
    @shivanshmahajan2281 3 месяца назад

    Finnally wait is over 😊

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

    Striver is god !!
    Thank you sir !!

  • @unknown72900
    @unknown72900 3 месяца назад

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

  • @user-il9wr5du1y
    @user-il9wr5du1y 3 месяца назад

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

    • @prasannasahoo0806
      @prasannasahoo0806 2 месяца назад

      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 .

  • @subee128
    @subee128 3 месяца назад

    Thank you very much

  • @harshvardhansankpal716
    @harshvardhansankpal716 3 месяца назад +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-ym1nv1pw8i
    @user-ym1nv1pw8i 23 дня назад

    Revise optimal @30:00
    Understood!
    Mark for revision

  • @xavier4107
    @xavier4107 3 месяца назад +1

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

  • @kashafkhan9726
    @kashafkhan9726 3 месяца назад +1

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

  • @sushma_1704
    @sushma_1704 3 месяца назад

    Thank u very much bhaiya

  • @Arya20012
    @Arya20012 3 месяца назад +1

    Thank you striver ❤, you are our hero

  • @ravigupta9784
    @ravigupta9784 2 месяца назад

    Thanks a lot🙂

  • @t-anime517
    @t-anime517 3 месяца назад

    guru dev dhanyawad🙏

  • @unemployedcse3514
    @unemployedcse3514 2 месяца назад

    awesome ❤

  • @navinchaudhary2812
    @navinchaudhary2812 3 месяца назад

    understood bhaiya

  • @codeman3828
    @codeman3828 3 месяца назад

    Thanks. Understood

  • @banothutharun2743
    @banothutharun2743 2 месяца назад

    superb bro

  • @Shivam-fl6uv
    @Shivam-fl6uv 3 месяца назад

    Thank You

  • @user-tk2vg5jt3l
    @user-tk2vg5jt3l 2 месяца назад

    Thank you bhaiya

  • @torishi82
    @torishi82 2 месяца назад

    Samaj aa gaya.

  • @tier3wala
    @tier3wala 3 месяца назад

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

  • @shahriaralom2903
    @shahriaralom2903 3 месяца назад

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

  • @prajyot2021
    @prajyot2021 22 дня назад

    thanks Raj

  • @rishabhnema2479
    @rishabhnema2479 3 месяца назад

    One playlist needed for greedy algo too.

  • @ok-jg9jb
    @ok-jg9jb 3 месяца назад

    Thanks❤

  • @thestarters9799
    @thestarters9799 3 месяца назад +1

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

  • @impatientgaming9868
    @impatientgaming9868 3 месяца назад

    Great

  • @JohnJoe-pd9ph
    @JohnJoe-pd9ph Месяц назад

    Nice

  • @NikhilKumar-xg7re
    @NikhilKumar-xg7re 3 месяца назад

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

  • @anujkapri6054
    @anujkapri6054 3 месяца назад +4

    Can we have playlist on strings. Please

  • @devshubham5528
    @devshubham5528 16 дней назад

    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

  • @RitikRaj-we2sc
    @RitikRaj-we2sc 3 месяца назад

    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 ?

  • @saketjaiswal9381
    @saketjaiswal9381 3 месяца назад

    Done Sir😎

  • @SanjeevM-yc5uj
    @SanjeevM-yc5uj 3 месяца назад

    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?

  • @parth2439
    @parth2439 3 месяца назад

    LETS GOO...

  • @sparshyadav9709
    @sparshyadav9709 3 месяца назад

    Understood.

  • @aniketrangari8679
    @aniketrangari8679 2 месяца назад

    simplest way to learn

  • @akashsoam7581
    @akashsoam7581 3 месяца назад +1

    we a similar small playlist for prefix sum

  • @labadepradip7734
    @labadepradip7734 3 месяца назад

    completed

  • @nayeemrafsan356
    @nayeemrafsan356 3 месяца назад

    this content is invaluable! can't thank you enough

  • @Chai_parathe
    @Chai_parathe 3 месяца назад +2

    Striver pls make string playlist 🥺

  • @dipendrasingh4874
    @dipendrasingh4874 3 месяца назад

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

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

    Those who agree we need strings playlist.

  • @rishabhnema2479
    @rishabhnema2479 3 месяца назад

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

    • @ankittjindal
      @ankittjindal 3 месяца назад

      Check aditya verma sliding window playlist too bro

  • @rishabhnema2479
    @rishabhnema2479 3 месяца назад +1

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

  • @Dsa_withjay
    @Dsa_withjay 3 месяца назад

    ❤️

  • @abhinavnarula7300
    @abhinavnarula7300 3 месяца назад +2

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

    • @AjithKumaR-jw9wt
      @AjithKumaR-jw9wt 3 месяца назад

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

  • @kanishkbairagi409
    @kanishkbairagi409 2 месяца назад

    Request to striver. We want strings playlists

  • @iqube4636
    @iqube4636 3 месяца назад

    Will these work even if array consist of negative numbers?

  • @sultan_3006
    @sultan_3006 3 месяца назад +1

    Can anyone explain me (IN DETAIL) optimal approach of 2nd pattern. Thanks In Advance!!!

  • @prajwalrai2596
    @prajwalrai2596 3 месяца назад +1

    string playlist please

  • @harshavardhanyadlapalli4963
    @harshavardhanyadlapalli4963 2 месяца назад

    what happens if the array allowed to have negative numbers ?