Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- */
- class Solution {
- public:
- ListNode* middleNode(ListNode* head) {
- int cnt = 0;
- ListNode*cur = head;
- while(cur)
- {
- cur = cur->next;
- cnt++;
- }
- cnt/=2;
- while(cnt)
- {
- head = head->next;
- cnt--;
- }
- return head;
- }
- };
Add Comment
Please, Sign In to add comment