My issue
why my code was showing error,can you explain and can you give me the correct code
My code
int getMiddleElement (Node*head)
{
Node *fast = head, *slow = head;
while(fast && fast->next)
{
fast = fast->next->next;
slow = slow->next;
}
return (slow->val);
}
Learning course: Prepare for your DSA interviews
Problem Link: Find the Middle Practice Problem in Prepare for your DSA interviews - CodeChef