Correction : This is 15th Video Of Sliding Window Playlist As you might have seen the news on my Community post. Hence the delay in upload today. Since you are like my friends & family so I decided to share with you too. Thank you all for your condolences. Hope this video helps. Similar Problems : Leetcode - 560 & Leetcode - 1074 : kzbin.info/www/bejne/Y4S6o61vZc92i68
@souravjoshi22938 ай бұрын
🙏 Take care
@thekindspill8 ай бұрын
What happened ? I hope everything is fine
@aws_handles8 ай бұрын
Take care 🙏🏻 My condolences 💐
@ugcwithaddi8 ай бұрын
My condolences 🙏🏻
@wearevacationuncoverers8 ай бұрын
So sorry to hear for your loss. Please take care.
@gauravbanerjee28988 ай бұрын
I have never seen anyone in the community explaining a question with this much simplicity. Thank you so much bhaiya ❤❤ So sorry for your loss, take care ❤
@ankanbrahmachary65818 ай бұрын
so sorry for your loss.. but hats off to you for making every problem so easy by turning it into stories .. thanks for the crystal clear explanation
@kunalpatil.248 ай бұрын
What loss ?
@bhuppidhamii8 ай бұрын
no one teaches like u
@rithickchowdhury71168 ай бұрын
2nd approach hi pehle dimaag ma aya bt self doubt ka wajah sa lga Brute force ho jayega iss liya chorr diya tha and apka video dekhna lga😅
@mukhritgupta85968 ай бұрын
By far the best explanation I have come across on YT
@LogicArena018 ай бұрын
Thanks man. Your style of teaching never disappoints me, a lot of thanks to you ..
@AnkitMeena-d7o2 ай бұрын
Sir you are the best teacher 😊 I ever found. I have subscribed to you with all my email id
@wearevacationuncoverers8 ай бұрын
You are a true gem mik. no one can beat your level of explanation. please take care and may god give strength to you and your family.
@madhurmittal9438 ай бұрын
Sir you are teaching really great I watch your videos everyday and they are so good...I really appreciate it and hope you keep uploading them daily please
@EB-ot8uu8 ай бұрын
fantastic explanation. I will complete your sliding window playlist this weekend. thanks a lot
@ishaansharma65538 ай бұрын
bhaiya my condolences , hats of too you bhaiya even in such a situation you are posting videos , i want to be like you 😇
@harsh.jain228 ай бұрын
why condolences ? what happened 😥?
@ishaansharma65538 ай бұрын
@@harsh.jain22 bhaiyas nanaji got expired
@gursimransingh37078 ай бұрын
very nice explanation
@risky_07728 ай бұрын
Watched multiple solutions for 560 as well as 930 but no one explained the hashmap logic as clearly as you, awesome teaching !
@codestorywithMIK8 ай бұрын
❤️🙏
@souravjoshi22938 ай бұрын
thank you so much for your detailed explanations. always the best.
@pranjalpandey30778 ай бұрын
hats off to you bhaiya :)
@DevOpskagyaan8 ай бұрын
Best explanation
@kunalpatil.248 ай бұрын
Thank You!
@techyou61638 ай бұрын
The first approach is also very similar to remove zero sum lists
@umeshbisht10548 ай бұрын
Thanku bhaiya ❤
@sudhanshushekhar42228 ай бұрын
Excellent explanation ❤
@tutuimam33818 ай бұрын
Thanks ❤❤❤❤❤❤❤❤
@simnidhnidh91223 ай бұрын
both approaches are good but second one with sliding window is super easy so can i just do it with 2nd approach only and skip 1st approach?
@kmr35737 ай бұрын
and what about this example [0,0,0,1,1,0] and goal =2 ????
@kajalhargunani67574 ай бұрын
Hi, Please explain Count Subarrays With More Ones Than Zeros
@maritime_business8 ай бұрын
Sliding window approach was confusing! Why did we add zeros here if(sm==k) res+=1+zero; and not before making zero=0 i.e. here-> if(nums[i]==0) zero++; else {res+=zero; zero=0;} shouldn't we add zeros before reinitializing zero to 0 what if for any test case zero count resets before reaching the below condition ? (i tried its giving wrong answer i know but looking at the code it makes sense to add zero count before reinitializing zero to 0)
@pragatidas29108 ай бұрын
Sir, Can you please solve codeforces questions like those on binary search space and the atcoder dp sheet. That would be very helpful because no one explains the way you do. Thanks a lot in advance.
@deepanshuverma62375 ай бұрын
Hey all, Though mik tried his best and un-intentionally missed some cases so not blaming him. but here the explanationa and written code are different ep: nums = [0,1,0,0,1] , goal = 1 ans is 9 .
@solosanskar4908 ай бұрын
Bhaiya priority queue ka comparator ka concept video le aaao please
@shabananoor94238 ай бұрын
❤❤
@akworld27396 ай бұрын
your code and dry run is totally different because your i is also move with j
@codestorywithMIK6 ай бұрын
Hi there, Can you share where exactly your are pointing? It will help me to correct. Thank you ❤️
@akworld27396 ай бұрын
@@codestorywithMIK 35:48 inner while loop condition your i also move with j
@mohnishkumar68478 ай бұрын
From where to study sliding window?
@codestorywithMIK8 ай бұрын
Sliding Window is a small concept. But qs can be of different levels. So solving different qns will help - kzbin.info/aero/PLpIkg8OmuX-J2Ivo9YdY7bRDstPPTVGvN&si=YsGUj8rqeDSWLfe2 Will add more in this playlist soon
@mohnishkumar68478 ай бұрын
@@codestorywithMIK so I should directly start solving problems right? Just curious to know how you get to the approach? Any pattern?
@codestorywithMIK8 ай бұрын
@mohnishkumar6847 Like I mentioned there are similar patterns in which sliding window problems fall. See my pinned comment for similar problem. The more you solve the more you will understand about it.
@aryanZzz..8 ай бұрын
Bhaiya plz make video on leetcode 2831,also explain one thing that sb logo ne is question me explain nhi kiya jb window ka size reduce kiya hai tb agar maximum frequency wala element out of window jaa rha h tb bhi maxf(count of most frequent element in that window) ko same he rkha h reduce nhi kiya?? bohot confusion hora h isme
@ShivamTh4058 ай бұрын
class Solution { public: int longestEqualSubarray(vector& nums, int k) { int n = nums.size(); int maxFreq = 0; unordered_map mp; int i=0,j=0; while(j k) { mp[nums[i]]--; i++; } j++; } return maxFreq; } };
@ShivamTh4058 ай бұрын
is code ko dry run krke dekho smjh aa jaega yahn par hme at most k elements ko remove krna hai (0 elements bhi remove kr skte hai) window sirf isliye bna rahe hai taki ye pta chl ske agr kisi window mai maximum freq koi previous maximum frequency se jyda aa gyi or us window mai k ya usse kam elements hai to ham us window wali freq ko consider kr skte hai Eg: 44412335, k=2 pehle j 4th index(element 2) tak move krega kyuki yahn tak sirf two different elements hai (1 and 2) , iske baad jab j 3 pe jaega tab different elements ka count 3 ho jaega isliye window ka size reduce krna hai lekin maxFreq[i] ko minus nahi krna hai, kyuki ye possbility bhi hai ki aage koi jyda max freq na mile, us case mai hamara answer 3 (444) wala subarray hoga in 2 test cases pe dry run kro smjh aa jaega 4441233335 k=2 44413231335 k=2
@aryanZzz..8 ай бұрын
@@ShivamTh405 bhai kuch smjh nhi aya
@ShivamTh4058 ай бұрын
@@aryanZzz.. dry run kro bhai line by line code ko tab smjh ayega
@sanjaybhatt602 ай бұрын
I think its not going to work for this case [0,1,1,1,1] and goal = 3
@kanishkkala168 ай бұрын
Bhai log yeh btao How is this different from cnt of subarrays with sum k, is it because this one only contains nums more than 0 and so. Why can't we apply sliding window on subarrays with sum k and why can we apply sliding window on this one, basically tell me the 'whysss'
@souravjoshi22938 ай бұрын
This is exactly same as Leetcode-560 (subarrays with sum k). If you see, the code is exactly same as Leetcode-560. Copy paste the same code in 560, it passes all. Now, Coming to sliding window, In a standard sliding window approach, once the window_sum reaches the target (k), the standard algorithm involves simply moving the i pointer of the window forward to potentially find more subarrays. But in this case, Including a zero element in the subarray won't change the sum. As a result, even if the window_sum reaches the target (k) initially, we might miss further subarrays that also meet the goal by simply shrinking the window (moving i to right) as long as the sum remains equal to the goal. This is because the presence of zeros creates the possibility of combining them with elements encountered later to reach the target(k).
@kanishkkala168 ай бұрын
@@souravjoshi2293 yes yes, I did apply the pre sum, hash map thing on this my self, I was asking more for the sliding window which u have somewhat explained well, thnx🙌
@wearevacationuncoverers8 ай бұрын
@@souravjoshi2293thanks
@shivanshagarwala58368 ай бұрын
sliding window is not possible in other one. because of negative number (which will make entire shift left end shifting useless to shrink the size.)