L16. Sliding Window Maximum | Stack and Queue Playlist

  Рет қаралды 43,410

take U forward

take U forward

Күн бұрын

Пікірлер: 58
@kshitijsingh879
@kshitijsingh879 5 ай бұрын
We use a deque to maintain the k elements and find maximums easily. When we find an element in the array greater than the top element, we remove lower elements from the deque since the max is changing. We continue this until we find a bigger element in the deque than the current element in the array. When i > k - 1, we add the answer because our window is at least k elements wide. We also maintain the correct size by checking i - k
@akashadak4160
@akashadak4160 4 ай бұрын
nice summarisation
@Gokul-gkl
@Gokul-gkl Ай бұрын
yes but in the worst case it gives O(n*n)(~brute force) , which should be avoided right that's why we are using the extra space
@sohaildarwajkar9979
@sohaildarwajkar9979 4 ай бұрын
I dont comment usually but i would suggest to look the same que from his old playlist. He has explained better there.
@arunm619
@arunm619 29 күн бұрын
Only one person can do better than him. That's himself.
@amanpreetsinghbawa1600
@amanpreetsinghbawa1600 17 күн бұрын
Actually, if you look at the complete playlist he has actually helped build the NSE, PSE & monotonic stack based concepts. So if one follows that, the intuition for the above will be quiet easy. TBH I was able to figure out the intuition, but I got stuck as I had never applied Deque based DS yet so that was the learning for me.
@AtharvaRao0104
@AtharvaRao0104 5 ай бұрын
some unimportant info: deque is pronounced as “deck.” for eg: deck of cards .. it is short form of double-ended-queue .. anyway concept is important not names
@hwrsh
@hwrsh 2 ай бұрын
wow
@studystuff51
@studystuff51 5 ай бұрын
Bhaiya, after seeing you solve the example, without even seeing you write the pseudo code I was able to solve the question by myself. Thing is, I am not able to think of the approach till you solved the example. I don't know how to come up with the approach myself.
@SurajKumar-ku1lg
@SurajKumar-ku1lg 5 ай бұрын
best video on sliding window maximum problem
@sohaildarwajkar9979
@sohaildarwajkar9979 4 ай бұрын
cap
@himalayadebbarma-we4pt
@himalayadebbarma-we4pt 5 ай бұрын
Thanks Striver
@aashijain7578
@aashijain7578 2 ай бұрын
can we use a deque of size k 1. if deque empty: insert element -> update maxi 2. while size of deque < k: add element and update maxi 3. if size of deque == k: update our ans array with maxi and remove the first element from the deque.
@tazanteflight8670
@tazanteflight8670 4 ай бұрын
thanks for showing a unsorted data version. Data is never sorted!
@barathkumar3583
@barathkumar3583 4 ай бұрын
His previous video on same topic explains same concept very detaily
@SuvamoySamanta-n2x
@SuvamoySamanta-n2x 2 ай бұрын
yes bro
@CP_Danger
@CP_Danger Ай бұрын
i tried implementing a max queue but i dont know where I am failing , even chatgpt is not suggesting any good corrections. void push(queue& q,int& Max,int x){ if(x>Max) { q.push((x-Max)+x); Max = x; } else q.push(x); } void pop(queue& q,int& Max){ if(q.front() >= (Max + Max - q.front())){ Max = Max - (q.front()-Max); q.pop(); } else q.pop(); } int front(queue& q,int& Max){ if(q.front()>Max){ return Max; } else return q.front(); } vector maxSlidingWindow(vector& nums, int k) { int n = nums.size(); vector res(n-k+1); queue q; int maxq = -100000; for(int i = 0;i
@TOI-700
@TOI-700 3 ай бұрын
GOT YOU BOTHER RAJ
@karthi2174
@karthi2174 Ай бұрын
Hello everyone, my placements are starting in March 2025. I have started learning DSA using the TakeUforward SDE sheet and have completed the first 10 problems. However, I was able to understand only 3 of them, and I am struggling to build logic on my own. I am unsure if I am on the right track or where to start. Could you please give me some advice on how to approach solving problems independently and where I should begin? I have programming knowledge but need guidance. I am not aiming to join a big MNC company, but I want to prepare effectively.
@kishoregowda8210
@kishoregowda8210 26 күн бұрын
Here are few tips from my personal experience. 1) Get your basics strong. No matter how much time you spend on DSA, if you don't have your basics correct, you will struggle. 2) Try to visualize the problem. According to me if you are able to visualize the question, you have already solved 50% of the problem. 3) Try to start with basic questions like on string, arrays, recursion. Don't concentrate more on time complexity in the beginning, but you should be able to come up with brute force approaches. 4) Move to concept wise questions only once you have done the above pointers. This is the flow i followed Arrays -> Binary Search -> Sorting -> Linked List -> Stacks&Queues -> Greedy -> Binary Tree -> Graphs -> Dynamic Programming. You should be able to come up with optimized approach for all if you are looking for FAANG companies.
@sanketatmaram
@sanketatmaram 4 ай бұрын
understood!
@AamilAli2003
@AamilAli2003 2 ай бұрын
Who's here after 50/51 testcases passed 😢
@tnfdigen1350
@tnfdigen1350 6 ай бұрын
Bhya ❤👍👍
@oyeshxrme
@oyeshxrme 3 ай бұрын
thanks bhaiya
@sanchitdeepsingh9663
@sanchitdeepsingh9663 6 ай бұрын
thanks sir
@chanduhl7060
@chanduhl7060 Ай бұрын
From where can I understand it 😂
@abhinavabhi3568
@abhinavabhi3568 26 күн бұрын
Understood
@KartikeyTT
@KartikeyTT 6 ай бұрын
tysm sir
@DeadPoolx1712
@DeadPoolx1712 3 ай бұрын
UNDERSTOOD;
@shashankvashishtha4454
@shashankvashishtha4454 6 ай бұрын
understood
@zaffarzeshan1308
@zaffarzeshan1308 5 ай бұрын
striver not teaching well as compare with old video only expression giving
@rishabhkansal5811
@rishabhkansal5811 5 ай бұрын
Yes, I also felt the same. He is not teaching in this playlist like earlier all playlist
@Ayush37262
@Ayush37262 5 ай бұрын
I agreed. This Stack and Queue playlist is bad tbh. Bhai ek toh dono data structures ko ek hi playlist mein kyu add kar diya 🤦‍♂️
@crazymemes4080
@crazymemes4080 5 ай бұрын
Felt the same, i am going back and checking his old video:)
@Ayush37262
@Ayush37262 5 ай бұрын
Bhai course launch karne ke baad mindset pura badal jaata hai...
@vinamrasangal8436
@vinamrasangal8436 4 ай бұрын
@@Ayush37262 right
@TOI-700
@TOI-700 3 ай бұрын
SANK YOU, THANK YOU
@TOI-700
@TOI-700 3 ай бұрын
understooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooood !?!?!! IDK
@subhasrisb11tha28
@subhasrisb11tha28 3 ай бұрын
😄
@codmobile1866
@codmobile1866 6 ай бұрын
first
@WebSurfingIsMyPastime
@WebSurfingIsMyPastime 6 ай бұрын
Good post, slow down the releases and you’ll get more views. Nobody can handle viewing and reviewing and learning 3-4 leetcode problems a day. Maybe a speed of one every few days is better
@brainmosquito7
@brainmosquito7 6 ай бұрын
apni suggestion apne paas rkh
@sarveshkulkarni6287
@sarveshkulkarni6287 6 ай бұрын
That's personal issue, he's already working in a company so as per his valuable time he uploads video's just for us,insteading of asking him for slow releases you yourself can manage your time as you are in need not him.
@WebSurfingIsMyPastime
@WebSurfingIsMyPastime 6 ай бұрын
@@sarveshkulkarni6287 Of course I can manage my time. My suggestion is not for me, but for his channel. Most people will skip multiple videos if the speed of delivery is too fast. So (for his channel and engagement) I made the suggestion that he should slow the release, that way he will get more clicks. Monetizing youtube videos is not as simple as one would think. You only make money on the views during the first few days of the videos release. If he releases multiple videos and the majority of the engagement/views are not immediate, he will not get much money from releasing this content.
@anishsood3084
@anishsood3084 5 ай бұрын
@@WebSurfingIsMyPastime bro jisne padna vo channel search kr ke pad lega.
@gnanyadapa9666
@gnanyadapa9666 5 ай бұрын
​@@WebSurfingIsMyPastimeWhy are you considering that only first few days would account for the views? Think about the long run mate.
@fanofabdevillersandmathslo5960
@fanofabdevillersandmathslo5960 14 сағат бұрын
Understood
@piyushsinghdtu456
@piyushsinghdtu456 4 ай бұрын
understood
L17. The Celebrity Problem | Stack and Queue Playlist
16:17
take U forward
Рет қаралды 38 М.
Sliding Window Maximum | Leetcode
20:16
take U forward
Рет қаралды 267 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
I Sent a Subscriber to Disneyland
0:27
MrBeast
Рет қаралды 104 МЛН
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
Maximum Product Subarray - Best Intuitive Approach Discussed
20:27
take U forward
Рет қаралды 259 М.
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 549 М.
L5. Fruit Into Baskets | 2 Pointers and Sliding Window Playlist
30:02
take U forward
Рет қаралды 98 М.
5 Secrets to Stop Stuttering & Speak More Clearly!
12:44
Vinh Giang
Рет қаралды 83 М.
L12. Largest Rectangle in Histogram | Stack and Queue Playlist
31:42
take U forward
Рет қаралды 61 М.
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 371 М.
Simon Sinek's Advice Will Leave You SPEECHLESS 2.0 (MUST WATCH)
20:43
Alpha Leaders
Рет қаралды 2,6 МЛН
Sliding Window Technique + 4 Questions - Algorithms
27:25
QuanticDev
Рет қаралды 130 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН