Loading

单链表翻转(图解)

目录


    返回 我的技术栈(Technology Stack)



    /**
     * Definition for singly-linked list.
     * struct ListNode {
     *     int val;
     *     struct ListNode *next;
     * };
     */
    struct ListNode *ReverseList(struct ListNode *head)
    {
        struct ListNode *prev = NULL;
        struct ListNode *curr = NULL;
        while(head != NULL)
        {
            curr = head->next;
            head->next = prev;
            prev = head;
            head = curr;
        }
    
        return prev;
    }
    
    作者:mayicoder
    链接:https://leetcode-cn.com/problems/convert-binary-number-in-a-linked-list-to-integer/solution/cyu-yan-xian-fan-zhuan-zai-shi-yong-wei-i5bi5/
    来源:力扣(LeetCode)
    

    image


    posted @ 2021-08-19 16:37  言非  阅读(50)  评论(0编辑  收藏  举报