nikunjsoni

876

Mar 16th, 2021
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. };
RAW Paste Data