Minimum Number of Operations to Make Array Continuous - Leetcode 2009 - Python

  Рет қаралды 17,261

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 33
@MP-ny3ep
@MP-ny3ep Жыл бұрын
GREATEST CODING CHANNEL ON KZbin. PERIOD.
@peanutbutter785
@peanutbutter785 11 ай бұрын
I've watched your channel (NeetCode channel) almost 2 yrs. It always have been such a helpful. Thank you so much!
@shivam-codes
@shivam-codes Жыл бұрын
the best intuition you can get for any question is this guy for sure
@sayaksengupta4335
@sayaksengupta4335 Жыл бұрын
this video felt more like a therapy session. "Don't be sad that you couldn't do it. It was hard." Jokea apart, great video.
@binfos7434
@binfos7434 5 ай бұрын
I did solve it in my head the same way but it was O(n2). As for the optimization, it would have been difficult, so didn't use my brain for it. lol
@bushrakhan7204
@bushrakhan7204 Жыл бұрын
demn such a quick upload, i do dsa in java but i still watch your videos to get the intution
@ksvijayan06
@ksvijayan06 Жыл бұрын
I code in java but i watch the video for the neetcode logical approach for each and every problem
@StellasAdi18
@StellasAdi18 Жыл бұрын
Just superb. Hats off to way you explain and cover edge cases.
@ashkan.arabim
@ashkan.arabim Күн бұрын
god damn even that brute-force solution blew my mind
@sagarpatel6062
@sagarpatel6062 Жыл бұрын
Too good brother.. Nice explanation Thank Youu ! ❤
@--Nithin
@--Nithin Жыл бұрын
You make these so simple, no way I will ever come up with that solution.
@Vancha112
@Vancha112 Жыл бұрын
I'm guessing neither does he, you'll have to learn it from somewhere first. I don't think people just come up with non naive solutions for questions like this
@bakkks
@bakkks Жыл бұрын
The hardest idea to rationalize for me is that the optimal result array has to start with one of the numbers in the array. Because there are solutions that are just as good that don't - e.g. for the array [2,3,6] - the result [1,2,3] is just as good as [2,3,4] - requires 1 change.
@proofhundred986
@proofhundred986 Жыл бұрын
More Hard Challegens lets go, do More, Very insightful
@shreyasaini5840
@shreyasaini5840 Жыл бұрын
today I came up with the brute force approach on my own :)
@abdulmoomin007
@abdulmoomin007 Жыл бұрын
Thanks for this, Can we have a video on leetcode 1420. Build Array Where You Can Find The Maximum Exactly K Comparisons?
@anonymoussloth6687
@anonymoussloth6687 Жыл бұрын
My initial thought was to use binary search. If we can figure out for any x: is it possible to make x replacements and make the array continuous - if so, then we can apply binary search. But I am not sure how we can figure that out optimally
@plsgivemecat
@plsgivemecat Жыл бұрын
Hey man, thanks for such a fast upload. I watch your videos because I'm doing DSA in Python. I will be honest, I find your explanation a little fast. I agree I'm slow and I need a lot of examples to actually get the solution methodology in my head but I feel you either speak super fast or don't write out the complete step-by-step process before coding it up. However, I still appreciate that you give us a live coding solution and try the best you can. I am trying to improve my capacity to grasp things better too haha. Thanks again
@cesarfa-b3t
@cesarfa-b3t Жыл бұрын
I had a different intuition to use difference in sets but that times out and only works for 54 out 62 test cases :( def minOperations(self, nums: List[int]) -> int: res = inf current = set(nums) for num in nums: desired = set([x for x in range(num,num+len(nums))]) res = min(res, len(desired.difference(current))) return res
@Raymond-Wu
@Raymond-Wu Жыл бұрын
That's O(n^2) since you're creating a set of size n for every num. I had a similar n^2 idea to what was talked about in the video except I used a min heap instead of sorting. This was a hard problem today!
@zzz-mn2yy
@zzz-mn2yy Жыл бұрын
did your min heap idea worked?@@Raymond-Wu
@Raymond-Wu
@Raymond-Wu Жыл бұрын
@@zzz-mn2yyit worked but exceeded the time limit since it was n^2. It got stuck at a similar point to the post above.
@Cake-bz5bf
@Cake-bz5bf Жыл бұрын
Pls upload more videos on logic making problems
@hiepdo9691
@hiepdo9691 Жыл бұрын
thanks for this , very helpful
@theLonelyBandit6984
@theLonelyBandit6984 5 ай бұрын
Instead of 2 pointers, we can use Binary search
@Ashwin_1198
@Ashwin_1198 Жыл бұрын
Bro keep uploading leetcode videos
@committedeel1751
@committedeel1751 Жыл бұрын
Trying to overlook how the brute force O(n^2) would look like here but struggling...
@yashigupta5999
@yashigupta5999 Жыл бұрын
same, did you get it
@karuppasamy.r77
@karuppasamy.r77 Жыл бұрын
Nice Explanation man How to good at programming like you bro
@krateskim4169
@krateskim4169 Жыл бұрын
Awesome
@everydaylifeisgood
@everydaylifeisgood Жыл бұрын
man this one is hard alright. tough to find solution
@nafisatabassum4344
@nafisatabassum4344 Жыл бұрын
your solution does not give a correct output for multiple duplicate integers.
@NeetCodeIO
@NeetCodeIO Жыл бұрын
i believe it does since my submission worked, did it not work for you?
Number of Flowers in Full Bloom - Leetcode 2251 - Python
20:01
NeetCodeIO
Рет қаралды 13 М.
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН
Vampire SUCKS Human Energy 🧛🏻‍♂️🪫 (ft. @StevenHe )
0:34
Alan Chikin Chow
Рет қаралды 138 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
GIANT Gummy Worm #shorts
0:42
Mr DegrEE
Рет қаралды 152 МЛН
Number of Good Paths - Leetcode 2421 - Python
25:13
NeetCodeIO
Рет қаралды 13 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 1 МЛН
Minimum Operations to Reduce X to Zero - Leetcode 1658 - Python
14:00
Number of Music Playlists - Leetcode 920 - Python
21:36
NeetCodeIO
Рет қаралды 13 М.
Constrained Subsequence Sum - Leetcode 1425 - Python
20:52
NeetCodeIO
Рет қаралды 8 М.
Minimum Difficulty of a Job Schedule - Leetcode 1335 - Python
13:41
#behindthescenes @CrissaJackson
0:11
Happy Kelli
Рет қаралды 27 МЛН