Number of Flowers in Full Bloom - Leetcode 2251 - Python

  Рет қаралды 12,550

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 41
@gn01737625
@gn01737625 Жыл бұрын
Hi NeetCode, the length of people array is also 5*10^4(as same as flowers.length). 10^9 is the range of people's arrival time
@NeetCodeIO
@NeetCodeIO Жыл бұрын
Whoops, I misread that. I still believe the overall time complexity that i mentioned doesn't change though, correct me if i'm wrong.
@TechBytes208
@TechBytes208 Жыл бұрын
​@@NeetCodeIOactually their complexity is also correct since mlogn and nlogn are now same
@akhilasulgante9907
@akhilasulgante9907 Жыл бұрын
Saviour!! Also, am I missing something because it is mentioned as "1
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Great explanation as always. Thank you
@parthfilmz
@parthfilmz Жыл бұрын
Thanks man for uploading this one, was searching on yt for this problem ,could not find good explanation
@swanv951
@swanv951 Жыл бұрын
Nice solutions. A small optimization would be to not add flowers whose bloom has already ended to the 'end' heap. @NeetCodeIO, do you get the solutions for such problems in 15 or so mins, which would be required in a real interview?
@lazyemperor5182
@lazyemperor5182 Жыл бұрын
Lovin the vids keep em coming
@sudhanshupandey6096
@sudhanshupandey6096 Жыл бұрын
What about discrete Maths?Please Launch a course on it.
@abhinavnarula7300
@abhinavnarula7300 Жыл бұрын
Thanks for the intution NeetCode. i just wanted to ask you how do i recognize this pattern of problems like how should i even think about this sort of a solution of using heap in this question. Not only this question but for other hard questions as well.
@NeetCodeIO
@NeetCodeIO Жыл бұрын
In this case, this problem reminds me of an easier interval problem i solved, i think it was either Meeting Rooms I or II. (it's in the Neetcode 150 list)
@abhinavnarula7300
@abhinavnarula7300 Жыл бұрын
@@NeetCodeIO Thank u very much ❤️❤️❤️
@createthiscom
@createthiscom 6 ай бұрын
Two sorted arrays also work to solve this problem, which is good if you're using something like JS that doesn't have native heap data types. It's twice as slow, but it's still "fast enough".
@xinruijiang6670
@xinruijiang6670 Жыл бұрын
Love this tutorial video! Just have a question. Why used heap sort here? Is heap sort better than other sorting algorithms in this case? Thanks. 😊
@enrico8730
@enrico8730 Жыл бұрын
Can’t wait for the oop design course!
@AliMalik-yt5ex
@AliMalik-yt5ex Жыл бұрын
Love the content 🎉
@pranav2066
@pranav2066 Жыл бұрын
Great solution. Slightly tougher to come up with in a real interview but at least you are making our thought process clearer. Just one thing, this question has been asked by Google, not Meta. Thumbnail is incorrect 😅.
@comatosesperrow
@comatosesperrow Жыл бұрын
Is there a reason we can't loop over each person, check if they are in the bounds of each flower, and increment a counter? It's O(m*n) runtime. I don't see complexity requirements in the question.
@alexsohn310
@alexsohn310 Жыл бұрын
That timed out for me
@satwiktatikonda764
@satwiktatikonda764 Жыл бұрын
hi neetcode,I used prefix sum and carry forward approach but it is giving memory error maxi=float('-inf') for l,r in flowers: maxi=max(maxi,r) zero=[0]*(maxi+1) for l,r in flowers: zero[l-1]+=1 zero[r]-=1 for i in range(1,len(zero)): zero[i]=zero[i-1]+zero[i] for p in people: if p-1>maxi: zero.append(0) else: zero.append(zero[p-1]) return zero[maxi+1:] I believe that this solution has linear time and linear space , can anyone help me with this!!
@pritz9
@pritz9 Жыл бұрын
Yeah ,even I came up with this approach, but mine passed 32/52 test cases and got memory limit exceeded after that!
@satwiktatikonda764
@satwiktatikonda764 Жыл бұрын
@@pritz9 the reason why it's not working is max value of r can be 10**9 and I am initialising zero array with size of 10**9 wch causes memory error
@pritz9
@pritz9 Жыл бұрын
@@satwiktatikonda764yeah I got that earlier, I just let u know that you aren't the only one :-(
@johnsimon8158
@johnsimon8158 22 күн бұрын
bro you need to draw the approach you use like actually draw 2 heaps and explain. In your drawing explanation you basically just drew what we could already see, and told the solution verbally only. 🙏🙏
@Andrew_J123
@Andrew_J123 Жыл бұрын
First!
@NeetCodeIO
@NeetCodeIO Жыл бұрын
🥇
@__sandeepkuyadav
@__sandeepkuyadav Жыл бұрын
can you please start coding in c++@@NeetCodeIO
@bekmurat7298
@bekmurat7298 11 ай бұрын
poeple 3:15
@rechw769
@rechw769 Жыл бұрын
hoho
@GeneralistDev
@GeneralistDev Жыл бұрын
I always find it hard to understand your approach/intution in videos. I don't know what's wrong with me unlike others why I don't understand your videos. May be accent, speed is fast etc.
@kareemadesola6522
@kareemadesola6522 Жыл бұрын
reduce the playback speed to 0.5 or customize to a value suited for you
@moneymaker7307
@moneymaker7307 Жыл бұрын
You are probably missing prerequisite. This problem is a simple line sweep problem. Unless you have mastered line sweep then the solution won’t make sense. You should probably do a lot easy intervals question before coming to this question
@CS_n00b
@CS_n00b 11 ай бұрын
why is this hard?
@anthonya880
@anthonya880 Жыл бұрын
Please consider making videos with Java also. May be you can reach a larger audience.
@sauravsingh4497
@sauravsingh4497 Жыл бұрын
Why would he use a verbose language
@phpostrich
@phpostrich Жыл бұрын
I feel like this should be a "medium" problem
@annoyingorange90
@annoyingorange90 Жыл бұрын
really unnecessary comment
@phpostrich
@phpostrich Жыл бұрын
Aren't all comments unnecessary?
@annoyingorange90
@annoyingorange90 Жыл бұрын
@@phpostrich ilooked it up already with the feeling of defeat no need to stomp on me :(
@phpostrich
@phpostrich Жыл бұрын
Oh I struggled a bit with this one too, but like compared to the other hard problems idk just seems a little easier
Find in Mountain Array - Leetcode 1095 - Python
12:39
NeetCodeIO
Рет қаралды 11 М.
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 12 МЛН
REAL 3D brush can draw grass Life Hack #shorts #lifehacks
00:42
MrMaximus
Рет қаралды 8 МЛН
Part 5. Roblox trend☠️
00:13
Kan Andrey
Рет қаралды 2,7 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 119 М.
Painting the Walls - Leetcode 2742 - Python
14:29
NeetCodeIO
Рет қаралды 14 М.
BEST MEETING POINT | LEETCODE 296 | PYTHON OPTIMAL SOLUTION
18:06
Cracking FAANG
Рет қаралды 2 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 453 М.
The LeetCode Fallacy
6:08
NeetCode
Рет қаралды 540 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 174 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 511 М.
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 12 МЛН