Linked List Cycle II | Live Coding with Explanation | Leetcode

  Рет қаралды 10,938

Algorithms Made Easy

Algorithms Made Easy

Күн бұрын

Пікірлер
@AlgorithmsMadeEasy
@AlgorithmsMadeEasy 4 жыл бұрын
We hope you all are enjoying our videos!!! Don't forget to leave a comment!!! Please like the video to support us!!! Questions you might like: ✅✅✅[ August Leetcoding Challenge ] : kzbin.info/aero/PLJtzaiEpVo2xu4h0gYQzvOMboclK_pZMe ✅✅✅July Leetcoding challenges: kzbin.info/aero/PLJtzaiEpVo2wrUwkvexbC-vbUqVIy7qC- ✅✅✅June Leetcoding challenges: kzbin.info/aero/PLJtzaiEpVo2xIfpptnCvUtKrUcod2zAKG ✅✅✅May Leetcoding challenges: kzbin.info/aero/PLJtzaiEpVo2wRmUCq96zsUwOVD6p66K9e ✅✅✅Cracking the Coding Interview - Unique String: kzbin.info/aero/PLJtzaiEpVo2xXf4LZb3y_BopOnLC1L4mE Struggling in a question?? Leave in a comment and we will make a video!!!🙂🙂🙂
@williamherman2001
@williamherman2001 2 жыл бұрын
"Make algorithms easy" But "Go and Google the intuition / maths behind this code yourself". How do you think people got here in the first place?
@himanshibaranwal7297
@himanshibaranwal7297 3 жыл бұрын
It took me a longtime to understand why the second while loop was even implemented. Would have been helpful if you would have explained with a proper diagram in each iterations. Also, this is an important question and opens up more possibilities of thinking area. So, diagrams with each iterations would have made it smooth.
@parthudgirkar9396
@parthudgirkar9396 Жыл бұрын
Could you explain it?
@Aryan-ji2nk
@Aryan-ji2nk Жыл бұрын
What's the point of writing the solution directly if you are not explaining the underlying logic? Solutions are available on the website itself
@aviksarkar8673
@aviksarkar8673 Жыл бұрын
Bhai Listen... Without explaining the process what is the point of doing Code?
@abhiram6087
@abhiram6087 3 жыл бұрын
@Algorithms Made Easy how did get the inspiration for the second while loop?
@torufujinami9558
@torufujinami9558 3 жыл бұрын
Many people have already posted about the solution part. But no one explains about the mathematical part of why the fast and slow pointer meets exactly at the start of the loop. I put dislike for that reason.
@akshattrivedi8837
@akshattrivedi8837 2 жыл бұрын
it isn't necessary where they meet, but it is definite that those both pointers will meet. For proper explanation watch neetcode channel's video on linked list cycle 141 problem. He explains it in diagram and has a good explanation, as 141 and 142 are similar problems
@kunalkheeva
@kunalkheeva 2 жыл бұрын
where is the explanation?? I would rather learn from madam.
@adityarajmane695
@adityarajmane695 4 жыл бұрын
didnt understand the second part of code , how did you find the position of start of cycle ............?
@abhiram6087
@abhiram6087 3 жыл бұрын
I think by this time you would have understood the code but i just wanted to explain it. in the first part when fast==slow then fast will going to the head in second half if its not equal to null . that means fast will be out side of the cycle but slow will be moving in the circle at some point they will meet that will be the intersection point,
@handsomeabu
@handsomeabu Жыл бұрын
In The First While Loop It detects the cycle when the while loop ends because of the condition slow == fast that mean fast pointer has catch up with the slow pointer so that means fast and slow pointers are now at -4 node and if it didn't detect a cycle the fast pointer would be null so that's why there's a base case fast == null and fast.next == null. Now fast pointer is now back at head which is 3 (fast = head) and then the second while loops starts to detect where the tail is connected. It Is Universal that the distance from -4 to 2 and from 3 to 2 it will be same. the 2nd while loop will only end when the fast and slow will be equal that means they will meet at the same spot which 2. and you could return either of it.
@DiwakarShuklaALD
@DiwakarShuklaALD 2 жыл бұрын
wonder how you gained this much subs just by reading the code... Irony is you're not making this 'easy'
@rajatluthra9737
@rajatluthra9737 3 жыл бұрын
Why u made fast =head ?
@siddharthb2226
@siddharthb2226 3 жыл бұрын
explain properly sir ji
@gokulvijayakumar1315
@gokulvijayakumar1315 2 жыл бұрын
I couldn't understand this part. Could you please explain while (slow2 != slow){ slow = slow.next; slow2 = slow2.next; }
@Stooeybear13
@Stooeybear13 2 жыл бұрын
Great video. For the second loop: while (fast != null && fast.next != null) { code...}, I clumsely put || instead of &&. I thought this would of been fine but i changed it to && and it worked. I kept getting a 'NullReferenceException'. Can someone explain how && is necessary for this to work? Trying to understand it.
@hazemkak
@hazemkak 2 жыл бұрын
because by in case fast is NULL now so fast.next is exception because there is no next for a NULL and by putting || you make the program check both conditions but by using && if the first condition fail which is fast != NULL '"indeed it equals NULL in the example now" so the program won't check the other condition & won't cause an exception
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
L6. Odd Even Linked List | Multiple Approaches
24:05
take U forward
Рет қаралды 122 М.
Leetcode - Linked List Cycle II (Python)
5:58
Timothy H Chang
Рет қаралды 13 М.
LEETCODE 142. Linked List Cycle II Explanation + Code
10:19
Code with Alisha
Рет қаралды 11 М.
Top 7 Data Structures for Interviews Explained SIMPLY
13:02
Codebagel
Рет қаралды 255 М.
Reverse Linked List II - Leetcode 92 - Python
16:03
NeetCode
Рет қаралды 91 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 681 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН