阅读背景:

LeetCode 206. Reverse Linked List 时间复杂度(O( n))

来源:互联网 

 时间复杂度(O( n))

class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        if(head==NULL||head->next==NULL)return head;
        ListNode* p = head;
        while(p->next!=NULL){
            ListNode* q = p->next;;
            p->next = p->next->next;
            q->next=head;
            head = q;
        }
        return head;
    }
};class Solution {
public:



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: