Line Number 139,
fast is pointing to head->next why ?
in explanation slow and fast pointing at first element of the LL.
can u explain ?
Line Number 139,
fast is pointing to head->next why ?
in explanation slow and fast pointing at first element of the LL.
can u explain ?
@premang its becoz imagine both cases
1st n odd
1 2 3 is linklist slow =1 and fast=2 therefore fast comes on null and slow on 2 so it works
2nd n even
1 2 3 4 slow=1 fast=2 fast comes on 4 and slow on 2 so now mid = 2
so basically if you are considering mid as 2 in even u start from fast = head next while if u consider 3 as mid then both as head.
i hope your doubt is resolved if yes dont forget to mark the doubt as resolved
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.