C clean solution


  • 0
    B
    struct ListNode* reverseList(struct ListNode* head) {
      struct ListNode *prev=NULL,*cur=head,*next;
      while(cur){
        next = cur->next;
        cur->next = prev;
        prev = cur;
        cur = next;
     }
     return prev;
    }

Log in to reply
 

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