c++ simple


  • 0
    class Solution {
    public:
        ListNode* reverseList(ListNode* head) {
            ListNode *current=head,*previous=NULL,*next=NULL;
            while(current)
            {
                next          = current->next;
                current->next = previous;
                previous      = current;
                current       = next;
            }
            return previous;
        }
    };
    

Log in to reply
 

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