Yeah, YT has a time limit of 60 seconds which makes this tough. I post the same shorts on Instagram, which has a time limit of 90 seconds, they are usually easier to follow. This is my Instagram if anyone wants to follow: instagram.com/neetcodeio
@jayrigger7508 The speed is the slope. As far as solving it, you can calculate when they would reach the destination if there wasn't any other cars (distance/speed), then from front to back track keep a running max time and each time you increase it, it is a new fleet. The logic behind that is if a car would get there quicker than cars ahead of it, it becomes part of a fleet, if they arrive after all cars ahead, they are a new fleet.
It sucks because this is what whiteboarding interviews were for, literally visually solve the problem first with the interviewer -> code it out. Now with all virtual interviews, it’s much harder to communicate if you can’t verbalize exactly how you’re problem solving/thinking
Yeah My exp recently has been that intvwr dont wanna look how i find pattern or figure out a part of solution working in 30min but i just have to code 100% perfect most optimized solution
Thanks! Do you really need a stack? What about O(1) space just by scanning right to left. Compute arrival time of element R then scan leftwards with L pointer to skip all elements with earlier arrival times. Then increment your count. Snap the R pointer to L pointer. And repeat.
thanks for that great video, I have one question which is should I solve leetcode problems after finishing each topic (I mean solving problems on each specific topic) or should I wait until I finish the full DSA roadmap of whatever course I'm taking then start solving problems on the full DSA?
Why cant u use a small math problem which is DST to solve this .. by calculating the displacement from the target and we know the speed. So we would know which can reach first
This sounds good. But, in interviews online where we have to work on Google document, it’s not possible to do the visuals easily. Is there a solution to bring whiteboard experience of free hand writing in interviews with FAANG companies?
@@harryzhu Thanks. I opened this tool, but the default is still predefined shape templates. Under line, free scribbling line option is available. I guess it takes some practice to master it so that we can use them effectively in the interviews
1. The first list comprehension is useless ('zip(position, speed)' is sufficient) you just unpack and repack... 2. the stack is also not needed, you can reverse loop through the array, store the last element and add to a counter if the last time is less than the current time. 3. you gave a very good intuition, thank you!
This umm.. went over my head tbh. Although good for a quick revision for those who have already solved this or aware about the concept or the trick
Yeah, YT has a time limit of 60 seconds which makes this tough. I post the same shorts on Instagram, which has a time limit of 90 seconds, they are usually easier to follow.
This is my Instagram if anyone wants to follow: instagram.com/neetcodeio
@@NeetCode without any doubt, followed ✌️
My issue is the graph .. I can't see the speed correlation on it .
@jayrigger7508 The speed is the slope. As far as solving it, you can calculate when they would reach the destination if there wasn't any other cars (distance/speed), then from front to back track keep a running max time and each time you increase it, it is a new fleet. The logic behind that is if a car would get there quicker than cars ahead of it, it becomes part of a fleet, if they arrive after all cars ahead, they are a new fleet.
@@jayrigger7508the way I see the problem is that 5 catches up to 8 and 0 to 3, and that's two lines, and 10 is the 3rd. I don't get his graph at all
the second rule of leetcode is to figure out where to use a hashmap ;)
Underrated but best
for remaining ones use recursion tree
What means where? I firstly solve the problem with hashmap and then start think😂
@@feliche-demiannetliukh3703 lol
This problem doesn't require a hashmap, it's using monotonic stack.
Bro i didnt even understand the problem 😂
Number 0 rule of leetcode problem, understand and explain it to your followers.
The coding problems on sites like leetcode are always worded so strangely
It sucks because this is what whiteboarding interviews were for, literally visually solve the problem first with the interviewer -> code it out. Now with all virtual interviews, it’s much harder to communicate if you can’t verbalize exactly how you’re problem solving/thinking
Yeah
My exp recently has been that intvwr dont wanna look how i find pattern or figure out a part of solution working in 30min but i just have to code 100% perfect most optimized solution
Thanks! Do you really need a stack? What about O(1) space just by scanning right to left. Compute arrival time of element R then scan leftwards with L pointer to skip all elements with earlier arrival times. Then increment your count. Snap the R pointer to L pointer. And repeat.
Bro, you are one of the rare programming lecturers on RUclips that visualize the problems 😭
i remember learning this problem it was such a brilliant solution
How am i supposed to come up with that graph though
10% luck
20% skill
15% concentrated power of will
5% pleasure
50% pain, and
100% reason to remember the name
Math
So naive recomendation, the most difficult part of LC problems solving is to understand what is needed.
Yeah I do that too, but my problem is just turning my answer to code is hard..
lol I guess that only be fixed with time
Awesome explanation
LoL my brain was screaming union find union find!! Lol
Computer science interviews have gone rogue!
Why do you need to do the [list comprehension] instead of just calling sorted on the zip output?
Lowkey buying a drawing tablet levelled up my leetcode game 🎉
thanks for that great video, I have one question which is should I solve leetcode problems after finishing each topic (I mean solving problems on each specific topic) or should I wait until I finish the full DSA roadmap of whatever course I'm taking then start solving problems on the full DSA?
Beautiful ❤️
The array speed is enough to solve this problem just by comparing the speeds of those cars.
Fucking python man, I swear it already solves all the DS parts of any leetcode problem
Don’t think you understand what leet code is about
Do you think leetcode is about implementing a stack? Lmao
I don’t even know data structures or algo bc imma go to college this year and that seems hard
Why cant u use a small math problem which is DST to solve this .. by calculating the displacement from the target and we know the speed. So we would know which can reach first
Thats so easy to visualize. I could have told you 3 and Im a mechanical engineer.
What is the drawing tool you use?
At least leetcode gives you drawings, during the interview they wont give you any diagram or drawing so understanding the problem is harder.
what if sometimes we know how canit be done at least with brute BUT dont know how to code it or write ?????
just a math problem💀💀💀
Graph plotting is simply a math according to him😂😂
I thought he will say any math formula
The math he's referring to is simply the formula:
time = distance / speed
This sounds good. But, in interviews online where we have to work on Google document, it’s not possible to do the visuals easily. Is there a solution to bring whiteboard experience of free hand writing in interviews with FAANG companies?
google docs u can go to insert and then click drawing.. yw!
@@harryzhu Thanks. I opened this tool, but the default is still predefined shape templates. Under line, free scribbling line option is available. I guess it takes some practice to master it so that we can use them effectively in the interviews
Thanks now I know how many car fleets will reach 12 😮
What would be your #1 rule to approach a ZYLYTY code challenge?
Lol, that’s my question that I ask in interviews haha😂
For web dev roles right? Definitely needed and useful
Please add subtitles to your videos. It will help learn the subtitle readers like me.
With all this wisdom, google can’t give you decent search results results 😢
Differentiation?
On the femonsttation cars go from left to right... But finish line is on top ))) Still not clear))
One liner for all of y'all trying to fail your job interview 🙌
reduce(lambda fla, pair: (fla[0] + int((target - pair[0]) / pair[1] > fla[1]), max(fla[1], (target - pair[0]) / pair[1])), sorted(zip(position, speed), reverse=True), (0, -1))[0]
That's the ugliest code I've ever seen.
That got me 😂😂😂
I'm f'd up .
I dont get who would need to know this outside of high level engineers, machine learning, etc
Can you tell the problem name?
Car Fleet
@@NeetCode thank you bro 👍
high school math problem😂
Time to get back to farming
O1 will solve it for me
You made it more complicated dude
new shirt ?
Bro wants you to visualise in the middle of the interview of 40 mins 😂
1. The first list comprehension is useless ('zip(position, speed)' is sufficient) you just unpack and repack...
2. the stack is also not needed, you can reverse loop through the array, store the last element and add to a counter if the last time is less than the current time.
3. you gave a very good intuition, thank you!
Ted Mosby?
number #1 rule is to use chatgpt
just forget about this leetcode geek stuff. Real life is different
>Now it's just a math problem
Umm.........I don't think that makes it easier my good sir (good advice though, I'm just making a joke)
wow
that is linear programming
Ok
You need better lighting bro bro
I never get this question cause it’s to make no sense
Oh man, imma need a full video on this. I got lost
i got you chief: ruclips.net/video/Pr6T-3yB9RM/видео.html
@@NeetCodenon-clickable or copyable link 😢
😂😂
Bro you barely explained the problem
LeetCode is kind of a joke.