leetcode 反转链表

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* reverseList(struct ListNode* head) {
  
   
    if(head==NULL)
        return NULL;
        
     struct ListNode*prev=NULL;
     
    while(head!=NULL)
    {
        struct ListNode *temp;
        temp = head->next;
        head->next = prev;
        prev = head;
        head = temp;
    }
    return prev;
    
}
原文地址:https://www.cnblogs.com/pencilCool/p/4676189.html