leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0876.cpp (330B)


0 class Solution { 1 public: 2 ListNode *middleNode(ListNode *head) { 3 ListNode *fast, *slow; 4 fast = slow = head; 5 while (fast->next && fast->next->next) { 6 fast = fast->next->next; 7 slow = slow->next; 8 } 9 if (fast->next) slow = slow->next; 10 11 return slow; 12 } 13 };