当前位置:网站首页>206. 反转链表
206. 反转链表
2022-06-11 08:55:00 【拽拽就是我】
leetcode力扣刷题打卡
题目:206. 反转链表
描述:给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。
解题思路
1、链表反转常用代码,迭代;
2、反转之后pre就成了头结点了,所以直接返回pre就行;
原代码##
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode * pre = nullptr;
ListNode *cur = head;
while (cur) {
ListNode *temp = cur->next;
cur->next = pre;
pre = cur;
cur = temp;
}
return pre;
}
};
边栏推荐
- Android 面试笔录(精心整理篇)
- 面试官问了四个问题,总结了4个经验
- 指定环境下安装Jupyter
- 复制的代码格式混乱怎么办?
- M1 chip guide: M1, M1 pro, M1 Max and M1 ultra
- 光伏板怎么申请ASTM E108阻燃测试?
- LiveData 与 StateFlow,我该用哪个?
- Hibernate L2 cache
- Livedata and stateflow, which should I use?
- (2) Analysis of AAC source code from the perspective of architecture design - my livedata
猜你喜欢

面试官问了四个问题,总结了4个经验

剑指 Offer 21. 调整数组顺序使奇数位于偶数前面

【clickhouse专栏】新建库角色用户初始化

Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup

Heap can also be regarded as a tree structure. It is specified that the root node must be greater than or less than the left and right child nodes, but the size order of the left and right child nodes

使用express+mysql创建一个基于nodejs的后台服务

File system check of the root filesystem failed

Installation (detailed illustration) and use of SVN

Oracle learning (I)

处理RAW格式的图像,需要什么软件?
随机推荐
leetcode - 739. Daily temperature
Supplementary provision plan codeworks round 760 (Div. 3)
SQL基本查询
SAP OData development tutorial
SAP abap内表分类与增删改查操作
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
哪些Apple设备支持这次系统更新?来看你的旧Apple设备支持最新系统吗
SQL basic query
Sword finger offer 62 The last remaining number in the circle
c语言打印心形
Interprocess communication
EN 45545 R24氧指数测试方法解析
Android interview transcript (carefully sorted out)
室内膨胀型防火涂料根据BS 476-21 耐火标准测定需要符合几项?
一些学习记录i=
multiplication table
File system check of the root filesystem failed
Are the two flame retardant standards of European furniture en 597-1 and en 597-2 the same?
Implementation of CRF for named entity recognition
(1) AAC opening - lifecycle, livedata, ViewModel and source code analysis skills of core component principles (Reprint)