Advertisement
nikunjsoni

876

Mar 16th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     ListNode* middleNode(ListNode* head) {
  4.         ListNode* slow = head;
  5.         ListNode* fast = head;
  6.         while (fast != NULL && fast->next != NULL) {
  7.             slow = slow->next;
  8.             fast = fast->next->next;
  9.         }
  10.         return slow;
  11.     }
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement