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

  Рет қаралды 227,444

take U forward

take U forward

Күн бұрын

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

Пікірлер: 217
@vect0r678
@vect0r678 5 ай бұрын
Petition to Striver - We want string playlist ASAP!!
@JerickMamuric
@JerickMamuric 6 ай бұрын
Despite your busy schedule, you still manage to deliver invaluable content like this. I salute you, sir! Thank you very much for the teachings.
@varun1017
@varun1017 6 ай бұрын
Petition to Striver. We want strings.
@AJAYKUMARRAJPUT-gl4tm
@AJAYKUMARRAJPUT-gl4tm 6 ай бұрын
I'm also waiting for it
@mr.rexalan5576
@mr.rexalan5576 6 ай бұрын
yes we want strings
@insidious_681
@insidious_681 6 ай бұрын
Yes striver sir 🙌
@FilmLover65
@FilmLover65 6 ай бұрын
yes we want strings
@ShivaaySingh20
@ShivaaySingh20 6 ай бұрын
Yes , please make series on strings.
@rajatraj4297
@rajatraj4297 6 ай бұрын
gurudev aaj ka leetcode daily dekh ke socha tha, striver ka sliding window kab aayega. aur aapne sun bhi li 😌
@suryasaipalthi
@suryasaipalthi 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!
@angeldeveloper
@angeldeveloper 6 ай бұрын
Most awaited playlist🎉🎉🎉
@uditpanjiyar3203
@uditpanjiyar3203 6 ай бұрын
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 🙏🙏
@mansimishra7089
@mansimishra7089 6 ай бұрын
This is something I was wishing 2 days back. Thanks Bhaiya :)
@starringharsh
@starringharsh 5 ай бұрын
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 3 ай бұрын
while optimizing, you kinda have to expect the input that is the most time consuming.
@InWonderland-z2l
@InWonderland-z2l 2 ай бұрын
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
@arnav7050
@arnav7050 6 ай бұрын
Thumbnail upgrade crazyyy…thanx for your efforts….eagerly waiting for strings
@tasneemayham974
@tasneemayham974 6 ай бұрын
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!!
@sanskargupta2739
@sanskargupta2739 6 ай бұрын
Petition to striver: we want string playlist
@omkarshendge5438
@omkarshendge5438 2 ай бұрын
we do it while(r
@Arsun-77
@Arsun-77 Ай бұрын
in his terms he is conveying us as upto n-1 which is similar to r
@NavakanthNani-dz8ge
@NavakanthNani-dz8ge Ай бұрын
in better approch, he is applying while(rk), you can put as while(sum>k && l
@tanvirahammed3783
@tanvirahammed3783 6 ай бұрын
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.
@nefarious001
@nefarious001 4 ай бұрын
VOTE FOR STRING PLAYLIST
@kunalwadhai777
@kunalwadhai777 6 ай бұрын
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 6 ай бұрын
Striver bro---we want string palylist
@vishwaskalra8773
@vishwaskalra8773 6 ай бұрын
Today i was thinking when will striver be teaching Sliding Window nd here it comes 🎉
@xavier4107
@xavier4107 5 ай бұрын
Petition to Striver: We want playlists on Strings & Prefix Sum logic, heap & updated playlist on hashing
@DhruvBhavinJethva
@DhruvBhavinJethva 5 ай бұрын
Amazing explanation, but one input from my side would be that before updating the window, we should check if(l
@prasannasahoo0806
@prasannasahoo0806 4 ай бұрын
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 Ай бұрын
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 .
@RohitRaj-n7j
@RohitRaj-n7j 3 ай бұрын
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 3 ай бұрын
At 21:55, isn’t it important for the while loop to have one more condition i.e l
@Braveuser-x7j
@Braveuser-x7j 6 ай бұрын
King is back with DSA..
@abhay3545
@abhay3545 6 ай бұрын
Best intro of any series on KZbin 🎉
@omkharade9521
@omkharade9521 6 ай бұрын
My motivation to continue grinding.
@affanahammed6742
@affanahammed6742 6 күн бұрын
Strings and Heaps playlist much needed
@srishtipandey6068
@srishtipandey6068 6 ай бұрын
Please upload greedy and heaps playlist too #striver
@KartikeyTT
@KartikeyTT 6 ай бұрын
Greedy is coming next weekend
@sejalpawar7076
@sejalpawar7076 2 ай бұрын
Best video I have watched for Sliding window till date
@shwetanshusinha2690
@shwetanshusinha2690 6 ай бұрын
Was waiting for this playlist from a long time. Thank u so much sir
@ropurifiedwater
@ropurifiedwater 6 ай бұрын
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!!
@ibrahimlanre4285
@ibrahimlanre4285 6 ай бұрын
bro striver i am so grateful for all you do ...but please a simple request on the heaps and string playlist🙏
@Cool96267
@Cool96267 4 ай бұрын
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?
@atulwadhwa192
@atulwadhwa192 6 ай бұрын
Most awaited series
@harshvardhansankpal716
@harshvardhansankpal716 6 ай бұрын
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
@priyanshugagiya
@priyanshugagiya 6 ай бұрын
Optimization was so great 🥵 I never thought about improving 2n to n
@AyushPetwal-b3i
@AyushPetwal-b3i 6 ай бұрын
💯 / 10 teacher for dsa..
@dambar67
@dambar67 20 күн бұрын
Thanks for nice explanation.2nd pattern will not work for negative number right
@franciskp9117
@franciskp9117 6 ай бұрын
Hey man, was waiting for this playlist for a long time. Appreciate your efforts
@dracoadi6239
@dracoadi6239 3 ай бұрын
best concept explanation so far
@cryptojeetu7599
@cryptojeetu7599 Ай бұрын
Best video on sliding window
@thestarters9799
@thestarters9799 6 ай бұрын
For else if(sum > k) break; There may be negative elements in array right?
@debadityaghosh7612
@debadityaghosh7612 21 күн бұрын
what an explanation man!!!! Hats off🤩
@deepaksingh3533
@deepaksingh3533 16 күн бұрын
Hi Striver! I completed my master’s in mathematics in 2022 and have been working at **** using Java. I've been studying data structures and algorithms (DSA) for the past 4-5 months, but I'm struggling to follow a step-by-step approach. Can you suggest where I should start and how I can effectively tackle DSA problems?
@as_if
@as_if Ай бұрын
1. Sliding window 2. Recursion revision 3. Then I'll move on to hard questions of graph or tree
@blitztour5924
@blitztour5924 6 ай бұрын
Completed this amazing Video. Going to Blitz through every question/video now😈
@sahil_bagde
@sahil_bagde 27 күн бұрын
Starting me thoda problem hoga , but fir ek do baar dekhne pr samaz jata hai 😀
@a_13_balaji_k44
@a_13_balaji_k44 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
@sultan_3006
@sultan_3006 5 ай бұрын
I was also wondering why no one has commented on that part!
@prasannasahoo0806
@prasannasahoo0806 4 ай бұрын
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 3 ай бұрын
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 2 ай бұрын
basically we get that subarray sum in that iteration only. So no need to iterate the last element
@harshhpreet
@harshhpreet Ай бұрын
@@purushottam108 hey, why did you write while(r
@shahriaralom2903
@shahriaralom2903 6 ай бұрын
Today i was thinking when will striver be teaching Sliding Window nd here it comes (2)
@fangirltalent5402
@fangirltalent5402 2 ай бұрын
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
@starringharsh
@starringharsh 5 ай бұрын
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 4 ай бұрын
can you explain how ?
@starringharsh
@starringharsh 4 ай бұрын
@@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.
@rishabhnema2479
@rishabhnema2479 6 ай бұрын
One playlist needed for greedy algo too.
@monikayadav-wb6pu
@monikayadav-wb6pu 6 ай бұрын
Thank you so much ❤bhaiya apki sari videos kaffi helpful rahi hai hamare liye
@AlvinOctaviano-k1m
@AlvinOctaviano-k1m 13 күн бұрын
Very good explanation
@ParthKamal-iy9bf
@ParthKamal-iy9bf 4 ай бұрын
you are doing great work striver
@rizmaaggarwal3389
@rizmaaggarwal3389 24 күн бұрын
very good work. thanks alot for doing this.
@anujkapri6054
@anujkapri6054 6 ай бұрын
Can we have playlist on strings. Please
@aishwarya156
@aishwarya156 6 ай бұрын
Awesome Bro! Great teaching skills!
@rishabhnema2479
@rishabhnema2479 6 ай бұрын
Thank you Sir! There was no playlist or videos regarding two pointers or sliding window on KZbin. Leetcode daily is asking problems related to it currently, would prove to be of great help.
@ankittjindal
@ankittjindal 6 ай бұрын
Check aditya verma sliding window playlist too bro
@saibhanu4142
@saibhanu4142 2 ай бұрын
Sir a small doubt , for (i=0 --> n-1) doe this mean for(i=0;i
@NikhilKumar-xg7re
@NikhilKumar-xg7re 6 ай бұрын
Much needed playlist btw which app do you use for notes ?? what is the name of this app ??♥♥♥
@rishabhnema2479
@rishabhnema2479 6 ай бұрын
Could you please add additional problems where instead of sum, product of subarrays pattern is taken.
@hashcodez757
@hashcodez757 Ай бұрын
UNDERSTOOD BHAIYA!!
@hawkop2386
@hawkop2386 2 ай бұрын
Bro do more videos based on these kind of approaches bro
@UECAshutoshKumar
@UECAshutoshKumar 18 күн бұрын
Thank you
@Biradar_Ganesh
@Biradar_Ganesh 6 ай бұрын
Thank you so much for this playlist sir 🙏🏻🫂❤️
@tier3wala
@tier3wala 6 ай бұрын
Thanks for Sharing bhaiya !! Stack ka v upload kar divine !! ❤️🫠
@kashafkhan9726
@kashafkhan9726 6 ай бұрын
Was in waiting ✋️ list for this from a long time ⏲️.
@omniamahmoud6604
@omniamahmoud6604 14 күн бұрын
Amazing video 👏
@RitikRaj-we2sc
@RitikRaj-we2sc 6 ай бұрын
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 ?
@dipendrasingh4874
@dipendrasingh4874 6 ай бұрын
bhaiya aaj ke contest me first time 3 question hua 🙂🙂🙂🙂because of you thank you
@prayasjain8104
@prayasjain8104 2 ай бұрын
New to DSA, Want to understand for 2nd pattern Longest subarray where sum
@marsymoyhailu9083
@marsymoyhailu9083 19 күн бұрын
the video was very nice but in the better solution when only one element is higher than 14 the left pointer moves on and passes the right one
@Arya20012
@Arya20012 6 ай бұрын
Thank you striver ❤, you are our hero
@shivanshmahajan2281
@shivanshmahajan2281 6 ай бұрын
Finnally wait is over 😊
@survivourff7014
@survivourff7014 6 ай бұрын
Tnq so much striver bhaiya...
@newbie8051
@newbie8051 2 ай бұрын
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 6 ай бұрын
Striver pls make string playlist 🥺
@whamjampamham
@whamjampamham 5 ай бұрын
Those who agree we need strings playlist.
@eesnehhil
@eesnehhil 5 ай бұрын
Yessssss
@nayeemrafsan356
@nayeemrafsan356 6 ай бұрын
this content is invaluable! can't thank you enough
@akashsoam7581
@akashsoam7581 6 ай бұрын
we a similar small playlist for prefix sum
@aniketrangari8679
@aniketrangari8679 5 ай бұрын
simplest way to learn
@abhinavnarula7300
@abhinavnarula7300 6 ай бұрын
I have a small doubt in the 2nd pattern's better approach, shouldn't we also check for l
@AjithKumaR-jw9wt
@AjithKumaR-jw9wt 6 ай бұрын
Yes, at the end we can put a condition if r less than l mean r equal to l plus one
@Lakshya-f4l
@Lakshya-f4l 3 ай бұрын
Revise optimal @30:00 Understood! Mark for revision
@hat_awesome21
@hat_awesome21 6 ай бұрын
Thanks a lot bro 🙏 ❤️
@ganeshjaggineni4097
@ganeshjaggineni4097 4 ай бұрын
NICE SUPER EXCELLENT MOTIVATED
@t-anime517
@t-anime517 5 ай бұрын
guru dev dhanyawad🙏
@manikantareddy9454
@manikantareddy9454 4 ай бұрын
great work sir🙌
@SanjeevM-yc5uj
@SanjeevM-yc5uj 6 ай бұрын
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?
@CodeWithCuriosity
@CodeWithCuriosity 3 күн бұрын
what an explanation 🥵🤯
@kanishkbairagi409
@kanishkbairagi409 5 ай бұрын
Request to striver. We want strings playlists
@adityamaheshwari4250
@adityamaheshwari4250 Ай бұрын
Kya phaddu video h bhai!
@subee128
@subee128 6 ай бұрын
Thank you very much
@priyan8004
@priyan8004 5 ай бұрын
Man ! you are amazing.
@devshubham5528
@devshubham5528 3 ай бұрын
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
@LinhHoang-ml1qo
@LinhHoang-ml1qo 4 ай бұрын
thanks for your dedication !
@ritikanand3425
@ritikanand3425 6 ай бұрын
Thank You for the efforts
@KaranSingh-v7t3y
@KaranSingh-v7t3y 6 ай бұрын
Thanks for uploading 🙏
@rajsharmawatch
@rajsharmawatch 4 ай бұрын
petition to striver we want string playlist
@torishi82
@torishi82 4 ай бұрын
Samaj aa gaya.
@jacobblack2544
@jacobblack2544 Ай бұрын
Thanks striver chachu
23 NEW Midjourney Tips because I like you
23:28
Future Tech Pilot
Рет қаралды 10 М.
How To Get Married:   #short
00:22
Jin and Hattie
Рет қаралды 29 МЛН
How do Cats Eat Watermelon? 🍉
00:21
One More
Рет қаралды 12 МЛН
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 99 МЛН
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 10 МЛН
Javascript in 1 shot in Hindi part 2
10:16:12
Chai aur Code
Рет қаралды 487 М.
L4. Max Consecutive Ones III | 2 Pointers and Sliding Window Playlist
29:58
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 421 М.
L1. Introduction to Stack and Queue | Implementation using Data Structures
1:05:06
L5. Fruit Into Baskets | 2 Pointers and Sliding Window Playlist
30:02
take U forward
Рет қаралды 70 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 386 М.
Why does ∞ - ∞ ≠ 0?
6:12
BriTheMathGuy
Рет қаралды 13 М.
How To Get Married:   #short
00:22
Jin and Hattie
Рет қаралды 29 МЛН