【爆肝题解】❤️24❤️新手也能理解并学会的剑指offer题目❤️❤️剑指 Offer 24. 反转链表
本文章是❤️剑指 offer(第2版)❤️的内容,该专栏还有多篇优质内容在等待你观看,现在点击右上角点击这个————🚀订阅专栏🚀

🔆坚持刷算法
💎每天进步一点点
🚀冲冲冲冲冲冲冲冲冲冲
💯剑指 offer 剑指 offer
巧解力扣
- 题目💎🍭
- 代码💎🍭
- 反思💎🍭
题目💎🍭

代码💎🍭
递归写法
/*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/
class Solution {
public:ListNode* reverseList(ListNode* head) {if (!head || !head->next) return head;auto tail = reverseList(head->next);head->next->next = head;head->next = NULL;return tail;}
};迭代写法
/*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/
class Solution {
public:ListNode* reverseList(ListNode* head) {if (!head) return NULL;auto a = head, b = a->next;while (b) {auto c = b->next;b->next = a;a = b;b = c;}head->next = NULL;return a;}
};
反思💎🍭
看代码
看完文章后,估计你全学会了,加油,明天继续!!

给你7个棒棒糖🍭🍭🍭🍭🍭🍭🍭
觉得文章可以,果断❤️点赞❤️收藏❤️关注❤️
粉丝专属福利
🍓学习资料:含C/C++、算法、Mysql、Linux、后端等。
🍓行业资料:关注即可领取PPT模板、简历模板、行业经典书籍PDF。
🍓面试题库:由技术群里的小伙伴们共同投稿,热乎的大厂面试真题,持续更新中。
🍓交流加群:大佬指点迷津,你的问题往往有人遇到过,求资源在群里喊一声。
👇👇👇👇👇👇👇

💌 欢迎大家在评论区提出意见和建议!💌
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
