当前位置:网站首页>Leetcode206. Reverse linked list
Leetcode206. Reverse linked list
2022-07-07 22:39:00 【Small size big ha】
Leetcode206. Reverse a linked list
Title Description : Here's the head node of the list head , Please reverse the list , And return the inverted linked list .


Ideas : Ideas : Reverse the pointer .
That is, take a null pointer pre
loop
Take a pointer next by cur Next node of
cur Next node of Change it to pre
pre Change it to cur
Give Way cur Next node
return pre
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode* pre=nullptr;
ListNode* cur=head;
while(cur!=nullptr)
{
ListNode* next=cur->next;
cur->next=pre;
pre=cur;
cur=next;
}
return pre;
}
};
边栏推荐
- Pdf document signature Guide
- Overseas agent recommendation
- OpenGL job - texture
- Record a garbled code during servlet learning
- How pyGame rotates pictures
- Oracle advanced (VI) Oracle expdp/impdp details
- 使用 BlocConsumer 同时构建响应式组件和监听状态
- Ni9185 and ni9234 hardware settings in Ni Max
- Microservice Remote debug, nocalhost + rainbond microservice Development second Bomb
- Pyqt GUI interface and logic separation
猜你喜欢

Firefox browser installation impression notes clipping

Blender exchange group, welcome to the water group ~

新版代挂网站PHP源码+去除授权/支持燃鹅代抽

php 获取图片信息的方法

Ni9185 and ni9234 hardware settings in Ni Max

It's worth seeing. Interview sites and interview skills

UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xf9 in position 56: illegal multibyte sequence

Yarn开启ACL用户认证之后无法查看Yarn历史任务日志解决办法

Overseas agent recommendation

Pdf document signature Guide
随机推荐
反爬通杀神器
. Net automapper use
OpeGL personal notes - lights
Variables and constants
使用 CustomPaint 绘制基本图形
Revit secondary development - intercept project error / warning pop-up
Paint basic graphics with custompaint
Relationship between URL and URI
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Use blocconsumer to build responsive components and monitor status at the same time
Install mxnet GPU version
Revit secondary development - modify wall thickness
Ren Qian code compilation error modification
php 获取图片信息的方法
苹果在iOS 16中通过'虚拟卡'安全功能进一步进军金融领域
Aspose. Words merge cells
Redis集群安装
如何选择合适的自动化测试工具?
「开源摘星计划」Loki实现Harbor日志的高效管理
What is the difference between the three values of null Nan undefined in JS