【leetcode】Reverse Linked List(easy)

Reverse a singly linked list.

 

思路:没啥好说的。秒...

ListNode* reverseList(ListNode* head) {
        ListNode * rList = NULL, * tmp = NULL;
        while(head != NULL)
        {
            tmp = rList;
            rList = head;
            head = head->next;
            rList->next = tmp;
        }
        return rList;
    }

 

posted @ 2015-05-21 10:38  匡子语  阅读(159)  评论(0编辑  收藏  举报