class Solution {
public:
    ListNode* middleNode(ListNode* head) {
        if (head == NULL)
        {
            return nullptr;
        }
        vector<ListNode*> List;
        List.push_back(head);
        int count = 1;
        while (head->next != NULL)
        {
            ListNode* n = head->next;
            List.push_back(n);
            head = head->next;
            count++;
        }
        return List[count / 2];
    }
};

 

posted on 2018-09-27 18:26  Sempron2800+  阅读(110)  评论(0编辑  收藏  举报