C++ || Efficient || two-pointers || Tortoise and Hare Algo || TC: O(N), SC: O(1) || with Explanation
If you understand the approach please please upvote!!!\uD83D\uDC4D\nThanks :)\n\n##### Two Pointer Algortihm or Tortoise and Hare Algorithm :-\n Initialize the 
##### If you understand the approach please please upvote!!!\uD83D\uDC4D\n***Thanks :)***\n\n##### Two Pointer Algortihm or Tortoise and Hare Algorithm :-\n* Initialize the two pointers `slow` and` fast `at the head of linked list .\n* Now every time, `slow `moves 1 step at a time while `fast `is moves 2 steps at a time. When` fast` pointer arrives at the end,` slow` pointer will arrive right in the middle of our linked list.\n* Now just return the value of` slow` pointer .\n\n*Time Complexity: O(N/2)=O(N)\nSpace Complexity: O(1)*\n\n##### C++ code:-\n```\nclass Solution {\npublic:\n    ListNode* middleNode(ListNode* head) {\n        ListNode *slow=head;\n        ListNode *fast=head;\n        while(fast && fast->next){\n            slow=slow->next;\n            fast=fast->next->next;\n        }\n        return slow;\n    }\n};\n```\n
['Linked List', 'Two Pointers', 'C', 'C++']