0
点赞
收藏
分享

微信扫一扫

Oracle对比两表数据的不一致

206. 反转链表 - 力扣(LeetCode)

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* reverseList(struct ListNode* head) 
{
    if(head == NULL)
        return NULL;
    else
    {
        struct ListNode* oldhead = head;
        struct ListNode* newhead = NULL;
        while(oldhead)
        {
            struct ListNode* nextnode = oldhead->next;
            oldhead->next = newhead;
            newhead = oldhead;
            //迭代
            oldhead = nextnode;
        }
        return newhead;
    }
    
}
举报

相关推荐

0 条评论