void print_middle(Node *head){
Node *fast = head;
Node *slow = head;
while(fast && fast->next){
fast = fast->next->next;
slow = slow->next;
}
std::cout << slow->data << std::endl;
}
Watch the detailed explanation of the concepts on Youtube:
No comments:
Post a Comment