Linked List Cycle - Leetcode 141 - Linked Lists (Python)

  Рет қаралды 5,845

Greg Hogg

Greg Hogg

Күн бұрын

Пікірлер: 17
@GregHogg
@GregHogg 4 ай бұрын
Master Data Structures & Algorithms For FREE at AlgoMap.io!
@anna-plink
@anna-plink 3 ай бұрын
Great explanation for slow and fast pointers 👍 My solution to this problem was to reassign each node's value to 'seen'. And if I come up to a node that has value 'seen', then it must be in a loop
@GregHogg
@GregHogg 3 ай бұрын
That's actually a great idea
@yvettcodes
@yvettcodes Ай бұрын
I was solving this problem in the wrong way, but today I've learned about slow and fast pointers and how to use them. Thanks! Another successful solution :)
@tobinjoseph5469
@tobinjoseph5469 Ай бұрын
you and and neetcode should collab !
@praneetkomandur6576
@praneetkomandur6576 4 ай бұрын
better than neetcode I cant even lie
@GregHogg
@GregHogg 4 ай бұрын
😂
@chandrakanthVenisetty
@chandrakanthVenisetty 6 ай бұрын
Great explanantion, really liking it so far. Concise solutions. Coming to this solution, I dont think we need to add a dummy node and start iterating from there, because as per Floyd's algo, they would eventually meet. In the example above, fast and slow would meet in second loop iteration, it's just more computation that's all. Let me know your thoughts.
@theSuitCat
@theSuitCat 8 ай бұрын
Hey greg, was it always that easy for you to solve these problems ? I find it very difficult not to understan but to solve it on my own. btw your explanation is very good keep it up.
@GregHogg
@GregHogg 8 ай бұрын
Lol definitely not easy at first, don't worry:)
@DMcDy
@DMcDy 3 ай бұрын
Hi Greg! I'm just curious why create a dummy node at all? It seems like it works fine to just omit that and make slow = fast = head. Thanks for the video!
@praneetkomandur6576
@praneetkomandur6576 4 ай бұрын
Can I ask you something Greg. Are we supposed to think of solutions like this without tutorials? I find that humanly possible. I feel like im memorizing blind75 with understanding aswell but Im not sure if I'd be able to do any other problems (unless they're easy hashmap ones) Am I cooked for interviews or will the interviews most likely have blind75 type problems
@GregHogg
@GregHogg 4 ай бұрын
It's okay to memorize for a while, often the blind 75 teaches new important algorithms that you wouldn't come up with on your own
@Infinitely16
@Infinitely16 2 ай бұрын
It's just the situation that tech interviews are at, and it will just keep getting worse unfortunately. It is of course not valid, fair, or correct to expect someone to come up with this solution within 45 minutes (or less, depending on if there are follow-ups). No one in the world would be able to do it. This algorithm was devised by a computer science researcher and has a mathematical proof. So the absolute, only possible way to use this as a solution, is to have seen and practiced it before. So it's just a question of "hey have you seen this specific question before?"
@staywithmeforever
@staywithmeforever 8 ай бұрын
Great explanation
@GregHogg
@GregHogg 8 ай бұрын
Thank you so much :)
@bthulasikrishna9597
@bthulasikrishna9597 3 ай бұрын
Why it has O(n) time complex ?
Pacific Atlantic Water Flow - Leetcode 417 - Graphs (Python)
17:10
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 138 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 98 МЛН
Merge Two Sorted Lists - Leetcode 21 - Linked Lists (Python)
9:41
Reverse Linked List - Leetcode 206 - Linked Lists (Python)
8:02
3Sum - Leetcode 15 - 2 Pointers (Python)
9:42
Greg Hogg
Рет қаралды 13 М.
Clone Graph - Leetcode 133 - Graphs (Python)
13:38
Greg Hogg
Рет қаралды 3,9 М.
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 18 М.
Leetcode 141. Linked List Cycle (Python)
9:56
Pseudocoder Ravina
Рет қаралды 455
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 303 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН