Minimum Size Subarray Sum - Leetcode 209 - Python

  Рет қаралды 95,581

NeetCode

NeetCode

Күн бұрын

Пікірлер: 72
@kartiksoni825
@kartiksoni825 2 жыл бұрын
This is probably the best Leetcode channel on the internet. Thank you so much for the invaluable content. Your drawing explanations are gold!
@rongrongmiao3018
@rongrongmiao3018 2 жыл бұрын
Please do a video on the follow up question of this question: what do we do if there are negative numbers in the array. Thanks.
@spirner669
@spirner669 2 жыл бұрын
after watching so many problems done by u. For this problem i've came up with exactly the same solution
@nikhilvecha6192
@nikhilvecha6192 2 жыл бұрын
Many thanks to you sir, you're actually helping a lot of people by solving these questions
@udaykulkarni5639
@udaykulkarni5639 2 жыл бұрын
This guy is absolute Legend and has ability to make complicated problems look easy! Thanks man :) Keep up the good work.
@elvinjafarli6257
@elvinjafarli6257 2 жыл бұрын
Much appreciated, the explanation is way better than any Leetcode solution provided.
@summisahani6415
@summisahani6415 2 ай бұрын
Probably the most precise explanation. Thanks a lot. Keep posting.
@studbud-qw3yo
@studbud-qw3yo 9 ай бұрын
i was kinda confused on why you were not using if statement thanks for clearing my doubt you are a legend
@metin4yt
@metin4yt 2 жыл бұрын
What would be the solution if there would be negative numbers in the array?
@yash-uy5ym
@yash-uy5ym 4 ай бұрын
I thought this question had some trick in it but it's only a sliding window Great explanation ❤
@cutiex7357
@cutiex7357 2 жыл бұрын
Every time when I hear "Hi everyone welcome back" I'm excited!!!
@T3Deye
@T3Deye 2 жыл бұрын
mate you are not a real person
@saileshsriram3295
@saileshsriram3295 Жыл бұрын
This was a pretty complicated problem. Thanks a lot for helping me understand it.
@israaezzat2353
@israaezzat2353 2 жыл бұрын
Really feel relaxed when i am looking for a solution of a problem on youtube and find your vedio ❤❤
@abhishekpawar8458
@abhishekpawar8458 2 жыл бұрын
What a coincidence, I was just solving the same problem on Lintcode ! Thanks a lot for the upload, I have an upcoming google interview
@MistaT44
@MistaT44 2 жыл бұрын
Best of luck
@edwythefair5215
@edwythefair5215 2 жыл бұрын
Good luck!
@bhuppidhamii
@bhuppidhamii Жыл бұрын
lintcode?
@meirgoldenberg5638
@meirgoldenberg5638 5 ай бұрын
What do you make of the follow-up question, which asks us to come up with a worse solution that the sliding window one we already came up with?
@lingxu9697
@lingxu9697 2 жыл бұрын
Love you NC, best coding channel ever...
@slai2389
@slai2389 Жыл бұрын
Thank you, I was struggling to this question until I found your video
@anmolmittal5689
@anmolmittal5689 2 жыл бұрын
You are a good person, helping us in programming 😊. How do you build such algos ? Plz give us a path to stick to master DSA 🙏
@cfbf96
@cfbf96 Жыл бұрын
When neet say things like: "well this is easy solution" or "this is just a standard xyz algo" just makes a dumbhead like me feel even dumber.
@RachelDong-y4s
@RachelDong-y4s Ай бұрын
expend right until success, shrink left until fail
@serene7560
@serene7560 5 ай бұрын
can we check if r-l+1= 1 inside the while loop and return 1 if that's the case?
@GenerationX186
@GenerationX186 2 жыл бұрын
Love your videos. They're so helpful. Always leave more informed and with one more approach than before playing your video.
@hype-r3076
@hype-r3076 10 ай бұрын
What if the array contains all elements greater than the target then wouldn’t the time complexity run in O(n^2)?
@howardlam6181
@howardlam6181 Ай бұрын
1590 is basically this problem but needs to be equal not greater than
@budiman-kr5ug
@budiman-kr5ug 8 ай бұрын
so many people are helped because of you
@jugsma6676
@jugsma6676 2 жыл бұрын
Thank you, This would be my approach: import sys def min_sub_array(target, nums): l = 0 r = 1 if target == nums[l]: return 1 total = nums[l] + nums[r] min_len = sys.maxsize while r >= l and r < len(nums): if total == target: min_len = min_len if min_len < r-l+1 else r-l+1 l = l+1 r = r+1 total = sum(nums[l:r + 1]) elif total > target: min_len = min_len if min_len < r-l+1 else r-l+1 l = l+1 total = sum(nums[l:r+1]) else: r = r+1 total = sum(nums[l:r+1]) min_len = 0 if min_len == sys.maxsize else min_len return min_len
@butoyighyslain171
@butoyighyslain171 8 ай бұрын
I was thinking about an algorithm that would leverage sorting the nums in reverse order and I kinda feel like it could be possible
@balamurali8980
@balamurali8980 2 жыл бұрын
Can you please help in solving the question - 68. Text Justification. There is no explantation even in leetcode, please. Thank you so much for your valuable videos.
@akshaibaruah1720
@akshaibaruah1720 2 жыл бұрын
This solution (optimized) was pretty easy to come up with. But can you make a video on the follow up of this question i.e. do it in O(nlogn)
@pradeepranjan1309
@pradeepranjan1309 2 жыл бұрын
great... You makes coding fun
@shamanthsham513
@shamanthsham513 2 жыл бұрын
Isn't brute force solution's time complexity is O(n^2 logn) /O(n^3) ?
@ngneerin
@ngneerin 2 жыл бұрын
Beautiful solution
@leetcodeespanol59
@leetcodeespanol59 2 жыл бұрын
Gracias por el video otra vez! Gran ayuda que esta poniendo en youtube!
@Nick-uo2bi
@Nick-uo2bi 2 жыл бұрын
Please create a playlist for DSA and DP in python beacause there isn't any on KZbin yet.....it will help thousand of ppl.
@6priyanshu
@6priyanshu 2 жыл бұрын
my first comment ever on YT, you are an inspiration. please keep creating such awesome content !! you are helping community, thank you !
@adnanhowlader143
@adnanhowlader143 2 жыл бұрын
daily one problem from your channel,,thats the challenge I took
@MISIUYT
@MISIUYT 2 жыл бұрын
Solving this on my own took way too long :)
@nagendrabommireddi8437
@nagendrabommireddi8437 Жыл бұрын
@neetcode sir .in this question follow up is to solve this by binary search....please help me to do using binary search...atleast please give a hint how we can solve using binarysearch..please
@aleksandrajovanovic2631
@aleksandrajovanovic2631 7 ай бұрын
how can we do this with one passage through array??
@user-ft1rj5jh3n
@user-ft1rj5jh3n 2 жыл бұрын
Hi neetcode! Could you post a video on Knight Dialer? It would mean a lot! Thank youu
@setiyakitchen
@setiyakitchen 3 ай бұрын
what if the array contains negative too?
@procon4
@procon4 2 жыл бұрын
Is there a faster approach where you start at the index of the largest number in the list rather than the first?
@zolopane117
@zolopane117 2 жыл бұрын
I don’t think that works. Imagine the input array in example 1 was [2, 3, 1, 2, 3, 4] instead (basically just swapping the last two elements). If you jumped to the largest element, you’d hit the end of the list before ever reaching the max. It’s possible to add a conditional to check both sides of the max, but that might run into issues if you had an input like this: [2, 3, 2, 1, 1, 4, 1]
@procon4
@procon4 2 жыл бұрын
@@zolopane117 yeah I was thinking you’d expand outward from the largest item.
@weiyaoli6977
@weiyaoli6977 2 жыл бұрын
amazing! love it
@thepriestofvaranasi
@thepriestofvaranasi Ай бұрын
How do you do it so easily dude. I spent hours clueless trying to come up with stupid solutions.
@trungduong8225
@trungduong8225 6 ай бұрын
hey thanks for the great video, but I'm having a problem. I implemented the similar idea with python then submit, but it got error with the input of [1,2,3,4,5]. It said expected "3" but I dont see any valid window with that size. Can anyone help, thanks!
@trungduong8225
@trungduong8225 6 ай бұрын
oh it's greater than or equal to
@waltairwhite821
@waltairwhite821 2 ай бұрын
@@trungduong8225 lol thanks dude.. i feel dumb now
@vijethkashyap151
@vijethkashyap151 Жыл бұрын
Can anybody help me with understanding the complexity of the solution coded here?
@taimurshah5956
@taimurshah5956 2 жыл бұрын
What software do you use to draw? And how do you record it?
@plontulublalulu
@plontulublalulu 2 жыл бұрын
wait, they got rid of the "contiguous" part on the problem. Is it still contiguous?
@nikhil_a01
@nikhil_a01 2 жыл бұрын
Yes, it's still contiguous. A subarray is by definition contiguous. You can test it on LeetCode too. If they accepted non-contiguous elements then the solution to nums = [5, 1, 2, 3], target = 7 should be 2. Because [5] and [2] sum to 7. But their expected answer is 3 because [5, 1, 2] is the only contiguous subarray that sums to >= 7.
@numberonep5404
@numberonep5404 2 жыл бұрын
Very nice content as usual :3 !!
@yashpathak9285
@yashpathak9285 2 жыл бұрын
When are we getting a series for System Design ?
@NeetCode
@NeetCode 2 жыл бұрын
Hopefully next month!
@programming3043
@programming3043 2 жыл бұрын
Can anyone explain why its not O(n²)
@chenyan4444
@chenyan4444 2 жыл бұрын
Same question here.
@nikhil_a01
@nikhil_a01 2 жыл бұрын
Why would it be O(N^2)? The right pointer iterates through the entire array doing O(1) work each time. That's O(N). And the left pointer also iterates through the entire array in the worst case, doing O(1) work each time. That's also O(N). So the overall time is O(N).
@12.aryankumar45
@12.aryankumar45 2 жыл бұрын
First here today ig. Thank you so much for these videos .
@faisalabdulkadir9439
@faisalabdulkadir9439 2 жыл бұрын
Good day sir , I appreciate all the work u are doing , pls sir can u pls look at the increasing in order search tree question 897, I’m having a hard time understanding the recursion process used ,thank u sir
@vishwanathanr2851
@vishwanathanr2851 2 жыл бұрын
How many problems you solve per day ❤️
@MISIUYT
@MISIUYT 2 жыл бұрын
he said at least one, but sometimes more depending on the day.
@ghoshsuman9495
@ghoshsuman9495 4 ай бұрын
any one wants to practise please comment
@iamburntout
@iamburntout 10 ай бұрын
Is this a joke. how am i supposed to come up with it during the interview. anyway, great video as always.
@thepriestofvaranasi
@thepriestofvaranasi Ай бұрын
Practice. Do multiple sliding window problems and you'll be able to recognise the pattern. These are PHD level dissertations and you can't come up with your own if you haven't done similar problems before.
@yourcaremail
@yourcaremail 5 ай бұрын
bruh we can almost hear you, please decrease your voice volume a bit more
Continuous Subarray Sum - Leetcode 523 - Python
14:56
NeetCode
Рет қаралды 71 М.
Minimum Size Subarray Sum | Leetcode #209
22:10
Techdose
Рет қаралды 31 М.
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 6 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 133 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Subarray Sum Equals K - Prefix Sums - Leetcode 560 - Python
15:19
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 687 М.
Top K Frequent Elements - Bucket Sort - Leetcode 347 - Python
13:13
Coin Change - Dynamic Programming Bottom Up - Leetcode 322
19:23
Trapping Rain Water - Google Interview Question - Leetcode 42
23:21
Sum of Subarray Minimums - Leetcode 907 - Python
18:51
NeetCodeIO
Рет қаралды 35 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 197 М.
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33