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!!!🙂🙂🙂
@williamherman20012 жыл бұрын
"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?
@himanshibaranwal72973 жыл бұрын
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 Жыл бұрын
Could you explain it?
@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 Жыл бұрын
Bhai Listen... Without explaining the process what is the point of doing Code?
@abhiram60873 жыл бұрын
@Algorithms Made Easy how did get the inspiration for the second while loop?
@torufujinami95583 жыл бұрын
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.
@akshattrivedi88372 жыл бұрын
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
@kunalkheeva2 жыл бұрын
where is the explanation?? I would rather learn from madam.
@adityarajmane6954 жыл бұрын
didnt understand the second part of code , how did you find the position of start of cycle ............?
@abhiram60873 жыл бұрын
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 Жыл бұрын
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.
@DiwakarShuklaALD2 жыл бұрын
wonder how you gained this much subs just by reading the code... Irony is you're not making this 'easy'
@rajatluthra97373 жыл бұрын
Why u made fast =head ?
@siddharthb22263 жыл бұрын
explain properly sir ji
@gokulvijayakumar13152 жыл бұрын
I couldn't understand this part. Could you please explain while (slow2 != slow){ slow = slow.next; slow2 = slow2.next; }
@Stooeybear132 жыл бұрын
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.
@hazemkak2 жыл бұрын
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