Find the Duplicate Number - Floyd's Cycle Detection - Leetcode 287 - Python

preview_player
Показать описание


0:00 - Read the problem
2:32 - Drawing Explanation
14:31 - Coding Explanation

leetcode 287

#floyd #cycle #python
Disclosure: Some of the links above may be affiliate links, from which I may earn a small commission.
Рекомендации по теме
Комментарии
Автор

That's right. Even Floyd wouldn't have resolved this problem in 30 minutes. It goes on to say that given the nature of such requirements in an interview, certain solutions are best memorized so that you could use them in a different situation or if the same problem comes up again.

rajeshseptember
Автор

Your 1min introduction on this problem literally cracked up me :D Never think of saltiness can turn into such a fun intro. Will probably remember this problem and how to solve it for a long time :D Thanks for making this video!

shelllu
Автор

This is the best video of explanation of Floyd’s algorithm I have seen so far…

JihChiLee
Автор

I absolutely love the fact that you code the solution right in front of us while explaining it, whereas other coding YouTubers just show their already written code which sometimes becomes difficult to understand. Thanks a ton for your awesome videos <3<3

epsilonator
Автор

That proof explanation was very good.. Even other big channels have failed to do it so smooth. thanks

joeycopperson
Автор

Thank you so much for the video of clear explaination!

For the graph starting from 2:32, I think the outgoing pointer from node 0 should point at node 1 first. And then node 1 will point to node 3.
Skipping the node that is pointed by 0 will struggle at the situation that element in 0 index is already the anwser.

At last, really thank you for creating great website needcode with good videos of the explaination of solution!!

leungcheng
Автор

This is the only explanation of Floyd's algorithm that I could understand... Thanks for this video...

interviewprep
Автор

I believe the head node at 2:35 should be 1 and not 0.

1 --> 3 --> 2 <--> 4.

This may cause confusion for others, thought I'd point it out.

Alzmerch
Автор

GOAT explanation. Everyone advised me to just memorize the algorithm, you're the only person to explain it to me.

akankshasharma
Автор

Kudos! No one explained the algorithm better than this, thank you so much

unmeshchougule
Автор

These are the kind of questions that piss me the fuck off. if you get this question in an interview and missed out on class it's GG

Thank you for your explanation as always though, this channel is a gold standard

RM-bgcd
Автор

Difficult problem, hard to solve without prior experience on it. Thank you so much.

tanoybhowmick
Автор

Great solution and explanation but there's a small mistake in the linked list diagram. The first element is actually 1 and not 0.
Great work, thanks a lot!

bharathithal
Автор

Your explanation was very clear, easily understandable. Thank you

anshaneja
Автор

You know what when you said that it is very difficult to solve this in 30 mins even for the person who invented the algorithm made me relief. Thanks

gelvkzd
Автор

Thanks for breaking this down! I managed to crack it in time and space O(n) by myself, but space O(1) was a head-scratcher. Gayle McDowell’s "2.8 Loop Detection" in Cracking the Coding Interview had me thinking I needed a secret decoder ring. Found it here, and now I can finally put away the flashcards!

sulinPL
Автор

I will cry if I got this question in intervew

tinymurky
Автор

Very clean and understandable explanation. I would rewatch it for more times. Thank you for your great work!

harpercfc_
Автор

11:30 In the proof, the fast pointer was equal to P + 2c - x, but isn't that assuming the fast pointer only loops over the cycle once?

kevinwang
Автор

I like the fact that you disliked this problem

asdfasyakitori