206 链表逆置

    ListNode* reverseList(ListNode* head) {
        if(head== nullptr)
            return head;
        ListNode *rear= nullptr,*front=nullptr;
        while(head!= nullptr){
            front=head->next;
            head->next=rear;
            rear=head;
            head=front;
        }
        return rear;
    }
posted @ 2018-12-20 16:59  INnoVation-V2  阅读(105)  评论(0编辑  收藏  举报