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

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025
  • Notes/Codes/Problem links under step 10 of A2Z DSA Course: takeuforward.o...
    Entire playlist: • Two Pointer and Slidin...
    Follow us on our other social media handles: linktr.ee/take...

ความคิดเห็น • 261

  • @vect0r678
    @vect0r678 9 หลายเดือนก่อน +410

    Petition to Striver - We want string playlist ASAP!!

    • @bipinsingh1490
      @bipinsingh1490 2 หลายเดือนก่อน +3

      Kb Ayega job meh budda hoh jaunga?

    • @cr00723
      @cr00723 2 หลายเดือนก่อน

      @@bipinsingh1490 mai sochu mujhe mil kyu nhi rhi strings ki playlist

  • @varun1017
    @varun1017 10 หลายเดือนก่อน +944

    Petition to Striver. We want strings.

    • @AJAYKUMARRAJPUT-gl4tm
      @AJAYKUMARRAJPUT-gl4tm 10 หลายเดือนก่อน +9

      I'm also waiting for it

    • @mr.rexalan5576
      @mr.rexalan5576 10 หลายเดือนก่อน +8

      yes we want strings

    • @insidious_681
      @insidious_681 10 หลายเดือนก่อน +7

      Yes striver sir 🙌

    • @FilmLover65
      @FilmLover65 10 หลายเดือนก่อน +6

      yes we want strings

    • @ShivaaySingh20
      @ShivaaySingh20 10 หลายเดือนก่อน +4

      Yes , please make series on strings.

  • @JerickMamuric
    @JerickMamuric 10 หลายเดือนก่อน +71

    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 10 หลายเดือนก่อน +72

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

  • @suryasaipalthi
    @suryasaipalthi 10 หลายเดือนก่อน +18

    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!

  • @YAELGONZALESGFX
    @YAELGONZALESGFX หลายเดือนก่อน +8

    Thanks to your videos, I was able to enter the world of competitive programming and improve in DSA. Thank you so much!

    • @swapnil7142
      @swapnil7142 หลายเดือนก่อน

      bro, can i have your linked in ID

    • @YAELGONZALESGFX
      @YAELGONZALESGFX 12 วันที่ผ่านมา

      I don't have LinkedIn

    • @HelloWorld-z5n
      @HelloWorld-z5n 6 วันที่ผ่านมา

      what kind of dollar is that?

  • @vijay8310
    @vijay8310 3 หลายเดือนก่อน +3

    We lost your natural smile and natural energy.you are an inspiration to many.many people have been following your dsa sheet learning coding from scratch.hatsoff for your dedication towards work.hoping you come back with more energy.

  • @mansimishra7089
    @mansimishra7089 10 หลายเดือนก่อน +11

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

  • @uditpanjiyar3203
    @uditpanjiyar3203 10 หลายเดือนก่อน +14

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

  • @angeldeveloper
    @angeldeveloper 10 หลายเดือนก่อน +36

    Most awaited playlist🎉🎉🎉

  • @tasneemayham974
    @tasneemayham974 10 หลายเดือนก่อน +7

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

  • @arnav7050
    @arnav7050 10 หลายเดือนก่อน +9

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

  • @InWonderland-z2l
    @InWonderland-z2l 6 หลายเดือนก่อน +3

    these kind of template videos are so awesome. useful for revision + wraps up the entire concept and makes it so much easier to understand the modifications in the different problems

  • @akashddeepchitransh4537
    @akashddeepchitransh4537 3 หลายเดือนก่อน

    The energy this man pushes is just unmatchable.

  • @starringharsh
    @starringharsh 9 หลายเดือนก่อน +25

    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 7 หลายเดือนก่อน

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

    • @thearchitect0474
      @thearchitect0474 3 หลายเดือนก่อน

      @@antor.morsalin When looking to optimize, you should consider all cases and set up your code to shave off time or space wherever possible. But while calculating the time complexity, you should consider the most time consuming input.

  • @kunalwadhai777
    @kunalwadhai777 10 หลายเดือนก่อน +2

    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.

  • @Braveuser-x7j
    @Braveuser-x7j 10 หลายเดือนก่อน +4

    King is back with DSA..

  • @MajidAli-gx7gg
    @MajidAli-gx7gg 6 วันที่ผ่านมา

    thanks sir. i'm felling confident even before solving any specific problem to these pattern. concepts got clear now. Thanks a lot

  • @yashendrabadal4776
    @yashendrabadal4776 3 หลายเดือนก่อน +1

    i was here to revise , excellent JOB STRIVER !

  • @vishwaskalra8773
    @vishwaskalra8773 10 หลายเดือนก่อน +2

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

  • @tanvirahammed3783
    @tanvirahammed3783 10 หลายเดือนก่อน +45

    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.

  • @abhay3545
    @abhay3545 10 หลายเดือนก่อน

    Best intro of any series on TH-cam 🎉

  • @a_13_balaji_k44
    @a_13_balaji_k44 10 หลายเดือนก่อน +6

    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

    • @MrKnown05
      @MrKnown05 9 หลายเดือนก่อน +1

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

    • @prasannasahoo0806
      @prasannasahoo0806 8 หลายเดือนก่อน

      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 7 หลายเดือนก่อน +2

      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

    • @rahulmahajan2412
      @rahulmahajan2412 6 หลายเดือนก่อน

      basically we get that subarray sum in that iteration only. So no need to iterate the last element

    • @harshhpreet
      @harshhpreet 5 หลายเดือนก่อน

      @@purushottam108 hey, why did you write while(r

  • @iamnoob7593
    @iamnoob7593 25 วันที่ผ่านมา

    brilliant playlist striver , thank you , revising again and had lot of gaps , Thank you.

  • @sanskargupta2739
    @sanskargupta2739 10 หลายเดือนก่อน +122

    Petition to striver: we want string playlist

  • @master-the-programming
    @master-the-programming หลายเดือนก่อน

    can't be simpler than this, hats off to you

  • @omkarshendge5438
    @omkarshendge5438 6 หลายเดือนก่อน +1

    we do it while(r

    • @Arsun-77
      @Arsun-77 5 หลายเดือนก่อน

      in his terms
      he is conveying us as upto n-1 which is similar to r

    • @NavakanthNani-dz8ge
      @NavakanthNani-dz8ge 5 หลายเดือนก่อน

      in better approch, he is applying while(rk), you can put as while(sum>k && l

  • @RohitRaj-n7j
    @RohitRaj-n7j 7 หลายเดือนก่อน +2

    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 7 หลายเดือนก่อน

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

  • @DhruvBhavinJethva
    @DhruvBhavinJethva 9 หลายเดือนก่อน

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

    • @prasannasahoo0806
      @prasannasahoo0806 8 หลายเดือนก่อน

      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 .

    • @ippilisaisugandhasri9952
      @ippilisaisugandhasri9952 5 หลายเดือนก่อน

      you are right but after incrementing l we are also incrementing r, then both l and r will point to the second element where we start creating subarrays .

  • @sejalpawar7076
    @sejalpawar7076 6 หลายเดือนก่อน

    Best video I have watched for Sliding window till date

  • @shwetanshu13
    @shwetanshu13 10 หลายเดือนก่อน +1

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

  • @affanahammed6742
    @affanahammed6742 4 หลายเดือนก่อน +2

    Strings and Heaps playlist much needed

  • @ropurifiedwater
    @ropurifiedwater 10 หลายเดือนก่อน

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

  • @priyanshugagiya
    @priyanshugagiya 10 หลายเดือนก่อน +2

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

  • @nefarious001
    @nefarious001 8 หลายเดือนก่อน +72

    VOTE FOR STRING PLAYLIST

  • @thaman701
    @thaman701 10 หลายเดือนก่อน +38

    Striver bro---we want string palylist

  • @kashafkhan9726
    @kashafkhan9726 10 หลายเดือนก่อน +2

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

  • @amanpreetsinghbawa1600
    @amanpreetsinghbawa1600 3 หลายเดือนก่อน

    Good optimisation, I had never thought around much regarding the optimisation wrt length we have

  • @joshl3013
    @joshl3013 3 หลายเดือนก่อน

    Very good content! I will buy your course once I got a job

  • @franciskp9117
    @franciskp9117 10 หลายเดือนก่อน

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

  • @omkharade9521
    @omkharade9521 10 หลายเดือนก่อน +3

    My motivation to continue grinding.

  • @mathelinux-b8h
    @mathelinux-b8h 10 หลายเดือนก่อน +1

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

  • @AyushPetwal-b3i
    @AyushPetwal-b3i 10 หลายเดือนก่อน

    💯 / 10 teacher for dsa..

  • @debadityaghosh7612
    @debadityaghosh7612 4 หลายเดือนก่อน

    what an explanation man!!!! Hats off🤩

  • @atulwadhwa192
    @atulwadhwa192 10 หลายเดือนก่อน +1

    Most awaited series

  • @blitztour5924
    @blitztour5924 10 หลายเดือนก่อน

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

  • @shruti-m4e
    @shruti-m4e หลายเดือนก่อน

    what a great explanation Striver... Hats Off !!🤩🤩🙌🏻🙌🏻🫡

  • @Cool96267
    @Cool96267 8 หลายเดือนก่อน

    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?

  • @aishwarya156
    @aishwarya156 10 หลายเดือนก่อน

    Awesome Bro! Great teaching skills!

  • @dracoadi6239
    @dracoadi6239 7 หลายเดือนก่อน

    best concept explanation so far

  • @monikayadav-wb6pu
    @monikayadav-wb6pu 10 หลายเดือนก่อน

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

  • @rizmaaggarwal3389
    @rizmaaggarwal3389 4 หลายเดือนก่อน

    very good work. thanks alot for doing this.

  • @harshvardhansankpal716
    @harshvardhansankpal716 10 หลายเดือนก่อน +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

  • @cryptojeetu7599
    @cryptojeetu7599 5 หลายเดือนก่อน

    Best video on sliding window

  • @srishtipandey6068
    @srishtipandey6068 10 หลายเดือนก่อน +59

    Please upload greedy and heaps playlist too #striver

    • @KartikeyTT
      @KartikeyTT 10 หลายเดือนก่อน

      Greedy is coming next weekend

  • @dambar67
    @dambar67 4 หลายเดือนก่อน

    Thanks for nice explanation.2nd pattern will not work for negative number right

  • @sahil_bagde
    @sahil_bagde 4 หลายเดือนก่อน +2

    Starting me thoda problem hoga , but fir ek do baar dekhne pr samaz jata hai 😀

  • @ParthKamal-iy9bf
    @ParthKamal-iy9bf 8 หลายเดือนก่อน

    you are doing great work striver

  • @manikantareddy9454
    @manikantareddy9454 8 หลายเดือนก่อน

    great work sir🙌

  • @shahriaralom2903
    @shahriaralom2903 10 หลายเดือนก่อน

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

  • @omniamahmoud6604
    @omniamahmoud6604 4 หลายเดือนก่อน

    Amazing video 👏

  • @dipendrasingh4874
    @dipendrasingh4874 10 หลายเดือนก่อน

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

  • @DevilJim-p1s
    @DevilJim-p1s 28 วันที่ผ่านมา

    Thumbnail is lit tho❤

  • @thestarters9799
    @thestarters9799 10 หลายเดือนก่อน +2

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

  • @worthlessguy1621
    @worthlessguy1621 2 วันที่ผ่านมา

    great video as allwlays sir

  • @AlvinOctaviano-k1m
    @AlvinOctaviano-k1m 4 หลายเดือนก่อน

    Very good explanation

  • @nayeemrafsan356
    @nayeemrafsan356 10 หลายเดือนก่อน

    this content is invaluable! can't thank you enough

  • @ayanSaha13291
    @ayanSaha13291 2 หลายเดือนก่อน

    thanks brother! it helped a lot.

  • @Biradar_Ganesh
    @Biradar_Ganesh 10 หลายเดือนก่อน

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

  • @NikhilKumar-xg7re
    @NikhilKumar-xg7re 10 หลายเดือนก่อน

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

  • @hawkop2386
    @hawkop2386 6 หลายเดือนก่อน +1

    Bro do more videos based on these kind of approaches bro

  • @fangirltalent5402
    @fangirltalent5402 6 หลายเดือนก่อน

    Can someone please explain that in optimised solution,when sum is 16 it is still >14 so how did we move r since condition for r is if(sum

  • @JaiShriKrishna9-03
    @JaiShriKrishna9-03 6 หลายเดือนก่อน

    Sir a small doubt , for (i=0 --> n-1) doe this mean for(i=0;i

  • @devshubham5528
    @devshubham5528 7 หลายเดือนก่อน

    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

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 7 หลายเดือนก่อน

    NICE SUPER EXCELLENT MOTIVATED

  • @tier3wala
    @tier3wala 10 หลายเดือนก่อน

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

  • @RitikRaj-we2sc
    @RitikRaj-we2sc 10 หลายเดือนก่อน

    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 ?

  • @rishabhnema2479
    @rishabhnema2479 10 หลายเดือนก่อน

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

    • @ankittjindal
      @ankittjindal 10 หลายเดือนก่อน

      Check aditya verma sliding window playlist too bro

  • @shivanshmahajan2281
    @shivanshmahajan2281 10 หลายเดือนก่อน

    Finnally wait is over 😊

  • @whamjampamham
    @whamjampamham 9 หลายเดือนก่อน +2

    Those who agree we need strings playlist.

    • @eesnehhil
      @eesnehhil 9 หลายเดือนก่อน

      Yessssss

  • @newbie8051
    @newbie8051 6 หลายเดือนก่อน

    8:00 sort karke we can apply two pointer approach right ? As in 3sum and 4sum problems
    But fir wohi hai, array needs to be sorted

  • @Chai_parathe
    @Chai_parathe 10 หลายเดือนก่อน +2

    Striver pls make string playlist 🥺

  • @hashcodez757
    @hashcodez757 5 หลายเดือนก่อน

    UNDERSTOOD BHAIYA!!

  • @anujkapri6054
    @anujkapri6054 10 หลายเดือนก่อน +4

    Can we have playlist on strings. Please

  • @hat_awesome21
    @hat_awesome21 10 หลายเดือนก่อน +1

    Thanks a lot bro 🙏 ❤️

  • @abdullaaliyar9602
    @abdullaaliyar9602 5 หลายเดือนก่อน

    13:10 does the logic of break works if the arrays contains negative elements ?

  • @rishabhnema2479
    @rishabhnema2479 10 หลายเดือนก่อน

    One playlist needed for greedy algo too.

  • @as_if
    @as_if 5 หลายเดือนก่อน

    1. Sliding window
    2. Recursion revision
    3. Then I'll move on to hard questions of graph or tree

  • @A_Myth963
    @A_Myth963 10 หลายเดือนก่อน

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

  • @rajsharmawatch
    @rajsharmawatch 8 หลายเดือนก่อน

    petition to striver we want string playlist

  • @akashsoam7581
    @akashsoam7581 10 หลายเดือนก่อน +1

    we a similar small playlist for prefix sum

  • @Lakshya-f4l
    @Lakshya-f4l 7 หลายเดือนก่อน +1

    Revise optimal @30:00
    Understood!
    Mark for revision

  • @CodeWithCuriosity
    @CodeWithCuriosity 4 หลายเดือนก่อน

    what an explanation 🥵🤯

  • @ravikiranpandey6808
    @ravikiranpandey6808 3 หลายเดือนก่อน

    bro i have a question in returning maximum length of subarray if we return a maxm sum then you break a statment if we got a sum exceed greater then 15 but i have high chance to a another number is a negative number then its sum decrease and we got a longest sub array

  • @Fighter_Believer_Achiever
    @Fighter_Believer_Achiever 27 วันที่ผ่านมา

    Thank you very much sir!!!

  • @Arya20012
    @Arya20012 10 หลายเดือนก่อน +1

    Thank you striver ❤, you are our hero

  • @survivourff7014
    @survivourff7014 10 หลายเดือนก่อน

    Tnq so much striver bhaiya...

  • @Thethappiboy
    @Thethappiboy 3 หลายเดือนก่อน +1

    what is the use of maxlen= maxlen(maxlen , j-i+1) at 12:44

  • @KaranSingh-v7t3y
    @KaranSingh-v7t3y 10 หลายเดือนก่อน

    Thanks for uploading 🙏

  • @banothutharun2743
    @banothutharun2743 9 หลายเดือนก่อน

    superb bro