Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- ListNode* middleNode(ListNode* head) {
- ListNode* slow = head;
- ListNode* fast = head;
- while (fast != NULL && fast->next != NULL) {
- slow = slow->next;
- fast = fast->next->next;
- }
- return slow;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement