this is my 6ms sollution in CPP


  • 0
    F

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


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.