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!
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.
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 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.
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!!
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 🙏🙏
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
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.
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.
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
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;
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
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 .
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 .
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
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 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.
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?
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.
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 ?
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?
Petition to Striver - We want string playlist ASAP!!
Kb Ayega job meh budda hoh jaunga?
@@bipinsingh1490 mai sochu mujhe mil kyu nhi rhi strings ki playlist
Petition to Striver. We want strings.
I'm also waiting for it
yes we want strings
Yes striver sir 🙌
yes we want strings
Yes , please make series on strings.
Despite your busy schedule, you still manage to deliver invaluable content like this. I salute you, sir! Thank you very much for the teachings.
gurudev aaj ka leetcode daily dekh ke socha tha, striver ka sliding window kab aayega. aur aapne sun bhi li 😌
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!
Most awaited playlist🎉🎉🎉
This is something I was wishing 2 days back. Thanks Bhaiya :)
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.
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])
while optimizing, you kinda have to expect the input that is the most time consuming.
@@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.
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!!
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 🙏🙏
The energy this man pushes is just unmatchable.
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
Thumbnail upgrade crazyyy…thanx for your efforts….eagerly waiting for strings
Petition to striver: we want string playlist
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.
King is back with DSA..
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.
we do it while(r
in his terms
he is conveying us as upto n-1 which is similar to r
in better approch, he is applying while(rk), you can put as while(sum>k && l
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
At 21:55, isn’t it important for the while loop to have one more condition i.e l
Best intro of any series on TH-cam 🎉
VOTE FOR STRING PLAYLIST
Strings and Heaps playlist much needed
i was here to revise , excellent JOB STRIVER !
Today i was thinking when will striver be teaching Sliding Window nd here it comes 🎉
Striver bro---we want string palylist
Best video I have watched for Sliding window till date
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
I was also wondering why no one has commented on that part!
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
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
basically we get that subarray sum in that iteration only. So no need to iterate the last element
@@purushottam108 hey, why did you write while(r
Was waiting for this playlist from a long time. Thank u so much sir
My motivation to continue grinding.
Amazing explanation, but one input from my side would be that before updating the window, we should check if(l
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 .
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 .
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!!
Please upload greedy and heaps playlist too #striver
Greedy is coming next weekend
Most awaited series
💯 / 10 teacher for dsa..
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
Revise optimal @30:00
Understood!
Mark for revision
Optimization was so great 🥵 I never thought about improving 2n to n
Hey man, was waiting for this playlist for a long time. Appreciate your efforts
Good optimisation, I had never thought around much regarding the optimisation wrt length we have
best concept explanation so far
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.
can you explain how ?
@@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.
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?
Very good content! I will buy your course once I got a job
what an explanation man!!!! Hats off🤩
Those who agree we need strings playlist.
Yessssss
Best video on sliding window
bro striver i am so grateful for all you do ...but please a simple request on the heaps and string playlist🙏
Completed this amazing Video. Going to Blitz through every question/video now😈
Thank you so much ❤bhaiya apki sari videos kaffi helpful rahi hai hamare liye
1. Sliding window
2. Recursion revision
3. Then I'll move on to hard questions of graph or tree
Starting me thoda problem hoga , but fir ek do baar dekhne pr samaz jata hai 😀
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
you are doing great work striver
this content is invaluable! can't thank you enough
Awesome Bro! Great teaching skills!
Finnally wait is over 😊
For else if(sum > k) break;
There may be negative elements in array right?
Was in waiting ✋️ list for this from a long time ⏲️.
UNDERSTOOD BHAIYA!!
Today i was thinking when will striver be teaching Sliding Window nd here it comes (2)
Can we have playlist on strings. Please
very good work. thanks alot for doing this.
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
One playlist needed for greedy algo too.
Tnq so much striver bhaiya...
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.
Check aditya verma sliding window playlist too bro
Very good explanation
Thanks a lot bro 🙏 ❤️
Bro do more videos based on these kind of approaches bro
Thanks for nice explanation.2nd pattern will not work for negative number right
great work sir🙌
Amazing video 👏
petition to striver we want string playlist
thanks brother! it helped a lot.
Thank you striver ❤, you are our hero
Man ! you are amazing.
Thank you so much for this playlist sir 🙏🏻🫂❤️
wow finally 😍 . Thanks
bhaiya aaj ke contest me first time 3 question hua 🙂🙂🙂🙂because of you thank you
what an explanation 🥵🤯
Much needed playlist
btw which app do you use for notes ?? what is the name of this app ??♥♥♥
we a similar small playlist for prefix sum
guru dev dhanyawad🙏
Thanks for Sharing bhaiya !! Stack ka v upload kar divine !! ❤️🫠
thanks for your dedication !
Striver pls make string playlist 🥺
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
please bring strings as soon as possible ...waiting ..placements are near
NICE SUPER EXCELLENT MOTIVATED
Sir a small doubt , for (i=0 --> n-1) doe this mean for(i=0;i
Thanks for uploading 🙏
Could you please add additional problems where instead of sum, product of subarrays pattern is taken.
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 ?
33:59 Can we just do (total number of subbarrays)-(Subarray sum strictly greater than k+ Subarray sum strictly less than k)??
Kya phaddu video h bhai!
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?
follow his DSA Sheet and Videos. Also make sure you are trying Questions by your own after getting Concepts done.
Thanks a lot bhaiya 💙
God is here... Ab koi bhi qn aa jaye sliding window ka contest mei🤝
New to DSA, Want to understand for 2nd pattern Longest subarray where sum