Shortest Subarray with Sum at Least K | Leetcode 862

  Рет қаралды 37,910

Techdose

Techdose

Күн бұрын

Пікірлер: 59
@aniketbasu3865
@aniketbasu3865 2 жыл бұрын
in this provided code he made the dqueue deque dq; with integer data type replace it with long long new test case has been added in leetcode so due to overflow you will get wrong ans . so use long long
@girishgawai_08_11
@girishgawai_08_11 Жыл бұрын
Improper explanation
@tonyz2203
@tonyz2203 2 жыл бұрын
Just got an offer from amazon. Thank you so much for your videos. They helped me a lot when grinding leetcode🙏🙏
@jethalalnhk2409
@jethalalnhk2409 2 жыл бұрын
Can you plz tell time gap between 2nd round and 3rd round bcoz I cleared 2nd round 1.5 months ago but still haven't got round 3 mail and also i haven't got rejection mail.
@finchicoph
@finchicoph 17 сағат бұрын
omg, my back popped crouching at my computer. Very good teacher, 👏I understand everything you say. It's just that I don't think I can think of this on my own. I don't thing I can come-up with a solution to store (idx,sum) in a deque and arrange them monotonically. Like how does this all make sense before you know it? Fine!
@techdose4u
@techdose4u 16 сағат бұрын
You need to do it multiple times before it starts hitting you :)
@vijaytirukkovalluru4535
@vijaytirukkovalluru4535 2 жыл бұрын
Thanks for being a great teacher!
@udaysingh-zi9xq
@udaysingh-zi9xq 2 жыл бұрын
Hello Sir, if possible make a playlist of all important questions for interviews.This would help the community a lot! Your way of explanation is phenomenal that's why I am requesting you to provide these super helpful playlists here on youtube so that it helps those who can't afford resources.
@darshansimha2166
@darshansimha2166 2 жыл бұрын
Such an elegant and beautiful explanation. Thank you Surya Pratap 🙏🏽
@deepali-e6f
@deepali-e6f 2 жыл бұрын
I can't understand intuition behind this approach!! I have read many articles on leetcode also, but still...
@AJAYPAL-zu6lg
@AJAYPAL-zu6lg 2 жыл бұрын
Congratulations sir 🎉 for getting AIR 1 in Google kick start
@Pegasus02Kr
@Pegasus02Kr 2 жыл бұрын
From the example, when we insert (4,3) why do we have to leave (2,0) to deque? As subarray should be contiguous, doesn't it also have to removed as its left to newly considering index 3?
@harigovind11
@harigovind11 2 жыл бұрын
Think of this case. [2,-1,2], k = 3 . Now we will need to keep the index of first 2 in the array as well to get monotonically increasing value of complete subarray.
@Pegasus02Kr
@Pegasus02Kr 2 жыл бұрын
@@harigovind11 Thanks for the explanation. Your example gave me the point I was missing.
@randomguy4822
@randomguy4822 2 жыл бұрын
Sir you said , you only pop when sum is >= target , what if the array is [-12,-22,-33,5] and target is 4 , how would it work in this case ?
@vikneshcs4824
@vikneshcs4824 5 ай бұрын
Why monotonocity is preserved? What happens when we include negatives
@ethanz4928
@ethanz4928 Жыл бұрын
in the first solution sliding window one which you said it won't work. if the right till the end, why not keep the left index and doing a seperate for loop start from this left index and shrinking again?
@anshugangwar7344
@anshugangwar7344 2 жыл бұрын
Calculating Max Sum of Array with the following condition, If A[i] element contributing in max sum,than you can't consider A[i]-1 and A[i]+1 element for max sum contribution, if present in array . Note: Elements of the array can be repeated multiple times. It's unsorted. It can have 1 to n number of element. eg: int A[ ]={1,6,7,1,2,3,3,4,5,5,5,6,9,10}; If I consider 10 as contributing max sum, I can consider 9 and 11. (Here 11 is not present but 9 is present still we can’t consider it). If I consider 5 (total max sum contribution 5*3) but can’t consider 4 and 6. I have tried sorting and storing index and count in the ordered map. Also try to compare with unbounded knapsack criteria. Still, I was struggling with an optimal and clear idea to calculate. Any idea how to approach it .
@Yash-uk8ib
@Yash-uk8ib 2 жыл бұрын
Consider storing the elements into an array (hashing) and apply house robber (kind of, but the approach would be similar) on this freqency Array
@lovleshbhatt7797
@lovleshbhatt7797 7 ай бұрын
What is the intuition behind this algorithm and why monotonous increasing will work here, can anybody please explan?
@ekengineer9868
@ekengineer9868 Жыл бұрын
Such a smooth explanation !
@Gggggg172eyeyeurhuwue
@Gggggg172eyeyeurhuwue 2 жыл бұрын
Thanks for the solution, but what is the point of keep [2,0] and [4,3] in the queue, what does it represent ?, isn't it non-contiguos.
@sakshigupta7616
@sakshigupta7616 2 жыл бұрын
Think of this case. [2,-1,2], k = 3 . Now we will need to keep the index of first 2 in the array as well to get monotonically increasing value of complete subarray. So basically we can remove from deque only when the sum gets greater than k.. In other cases we should not delete it because it might be of use.
@suryasriram3090
@suryasriram3090 2 жыл бұрын
I'm new to programming, can anyone of you tell me which is the best way to start learning coding? And best platform(which has the complete content)? Any good Websites?/video courses?
@jimmyaghera1897
@jimmyaghera1897 Күн бұрын
nice explanation sirg
@techdose4u
@techdose4u Күн бұрын
thanks :)
@HarshhPrajapati
@HarshhPrajapati 2 жыл бұрын
🔥🔥🔥 Sir, on which software(Blackboard) are you writing this??
@guneetmalhotra01
@guneetmalhotra01 2 жыл бұрын
Hey, did you get it?
@HarshhPrajapati
@HarshhPrajapati 2 жыл бұрын
@@guneetmalhotra01 nope
@surajJoshiFilms
@surajJoshiFilms Жыл бұрын
Why popping elements from the deque won't affect the result?
@mk-mc8yx
@mk-mc8yx 2 жыл бұрын
I have not looked at Leetcode. I guess there are at least 1000 problems. How do one remember the logic, even after practicing or understanding the logic, I do tend to forget things. Guess its sign of aging :(
@shubhamthakur-wo4um
@shubhamthakur-wo4um 2 жыл бұрын
How would this logic work out for [2, -1, 2] and target = 3 ? As per the analysis, the final queue is [ (1,1) , (3,2)]. But the answer is 3.
@suryasriram3090
@suryasriram3090 2 жыл бұрын
Hi, can you tell me which is the best way to start learning coding? And best platform(which has the complete content)? Any good Websites?/video courses?
@singhontop
@singhontop 2 жыл бұрын
i am also stuck on then same case, did you find any solution for it?
@ENGCS_JaiSaxena
@ENGCS_JaiSaxena Жыл бұрын
Guys even if leetcode test case pass , this approach is wrong for generally solving the questions, thousands of test case will fail
@naniscompass3173
@naniscompass3173 2 жыл бұрын
What is the name of this tool (colour pens) which is your using to write on blackboard?
@girishgawai_08_11
@girishgawai_08_11 Жыл бұрын
it doesn't make sense if you only explains a single example, also you are saying delete it if still the sum is greater but in end when 18-8
@techstuff9830
@techstuff9830 Жыл бұрын
Sir what about binary search approach when binary search on possible lengths and finding if this length is possible or not by sliding window, why this approach is giving me wrong on 87/97
@atharvasingh5568
@atharvasingh5568 6 ай бұрын
The numbers are negative also in array thus thinking that increasing window size would increase sum is wrong
@MeraBaapHaiTu31
@MeraBaapHaiTu31 17 сағат бұрын
If your window of length say 5 is satisfying the sum then that doesn't ensure all more than 5 will satisfy as you are also having negative values so you will definitely miss the answer in binary search
@sailendrachettri8521
@sailendrachettri8521 Күн бұрын
Nice solution :)
@techdose4u
@techdose4u Күн бұрын
Yes, thanks
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
Such amazing explanation 😁😁
@Jeremy-yb5yo
@Jeremy-yb5yo 2 жыл бұрын
Stopped making new videos?
@latchireddiekalavya4683
@latchireddiekalavya4683 Жыл бұрын
nice explanation sir!!
@vineettomar2535
@vineettomar2535 2 жыл бұрын
Code not workingon leetcode now as few more test cases added
@bchen1403
@bchen1403 2 жыл бұрын
Great explanation with clear visualization.
@Truysジャ
@Truysジャ 2 жыл бұрын
Nice explanation sir
@Hrit
@Hrit 2 жыл бұрын
Clean Explanation. Thanks!
@guneetmalhotra01
@guneetmalhotra01 2 жыл бұрын
Can anyone tell me which blackboard software is this?
@manikk634
@manikk634 2 жыл бұрын
Not able to get the case with above approach is [5, 7, -12, 20, 5, 2, 1, 23] target =8 minimal subarray is -12, 20
@sakshigupta7616
@sakshigupta7616 2 жыл бұрын
minimal subarray would be 20 here cause it is greater than 8. It is giving right answer, I checked on leetcode.
@keerthivasan138
@keerthivasan138 2 жыл бұрын
Bro Did you Find any Valid answer
@ENGCS_JaiSaxena
@ENGCS_JaiSaxena Жыл бұрын
​@@sakshigupta7616then solve for this [7,-1,6,1,1,1] K= 9
@ChandraSekhar-tr7sf
@ChandraSekhar-tr7sf 2 жыл бұрын
Not so intuitive
@ismail8973
@ismail8973 2 жыл бұрын
💥💥
@techdose4u
@techdose4u 2 жыл бұрын
:)
@amitmannur8743
@amitmannur8743 2 жыл бұрын
cool solution but not upto mark in explaining ,
@hxx15
@hxx15 2 жыл бұрын
I love you bro
Shortest Subarray with Sum at Least K - Leetcode 862 - Python
27:57
Minimum Size Subarray Sum | Leetcode #209
22:10
Techdose
Рет қаралды 31 М.
When u fight over the armrest
00:41
Adam W
Рет қаралды 28 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 147 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 18 МЛН
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 6 МЛН
Shortest Subarray With OR at Least K II | Leetcode 3097
21:13
Techdose
Рет қаралды 3,7 М.
Shortest Subarray with Sum at Least K | O(N) solution | Leetcode - 862
35:17
Algorithms Made Easy
Рет қаралды 4,1 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 677 М.
Minimum Size Subarray Sum - Leetcode 209 - Python
12:30
NeetCode
Рет қаралды 95 М.
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 482 М.
Prefix Sums - Problems, Code in C++ & Python
20:51
Errichto Algorithms
Рет қаралды 56 М.
When u fight over the armrest
00:41
Adam W
Рет қаралды 28 МЛН