I have dry run it with both even and odd length linked lists and its fine… the conditions are also correct but my program stops working when it reaches this part.
please tell why is it not working…
I have dry run it with both even and odd length linked lists and its fine… the conditions are also correct but my program stops working when it reaches this part.
please tell why is it not working…
why are u writing so much code to find the mig point of linked list??
it just 3 lines code
ListNode* middleNode(ListNode* head) {
ListNode *s = head, *f = head;
while(f!= NULL and f->next!= NULL){
s = s->next;
f = f->next->next;
}
return s;
}
thanks it works… but what if i want the 2 midpoints for even length linked list?
kabhi pochte h nhi but then u can mantain prev pointer of slow node
then u can get ddata to both nodes
ok thanks again ma’am