摘要: 92. Reverse Linked List II 在链表头添加一个虚拟源点,可以减少特判 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() 阅读全文
posted @ 2024-10-07 03:14 Gold_stein 阅读(10) 评论(0) 推荐(0)
摘要: Leetcode 206. Reverse Linked List 包含循环和递归写法 class Solution { public: ListNode* reverseList(ListNode* head) { if (!head || !head->next) { return head; 阅读全文
posted @ 2024-10-07 00:31 Gold_stein 阅读(14) 评论(0) 推荐(0)