当前位置:网站首页>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;
}
};
边栏推荐
- 0-5vac to 4-20mA AC current isolated transmitter / conversion module
- Aspose. Words merge cells
- [open source] Net ORM accessing Firebird database
- Use json Stringify() to realize deep copy, be careful, there may be a huge hole
- 微服务架构开源框架详情介绍
- SAR影像质量评估
- Revit secondary development - shielding warning prompt window
- Blender exchange group, welcome to the water group ~
- Common verification rules of form components -2 (continuously updating ~)
- Revit secondary development - cut view
猜你喜欢

新版代挂网站PHP源码+去除授权/支持燃鹅代抽
Apple further entered the financial sector through the 'virtual card' security function in IOS 16

Matplotlib quick start

Form组件常用校验规则-2(持续更新中~)

#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA

Use json Stringify() to realize deep copy, be careful, there may be a huge hole

Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold

Crawler (17) - Interview (2) | crawler interview question bank

Customer case | China law network, through observing the cloud, greatly shortens the time of fault location

IP network active evaluation system -- x-vision
随机推荐
Firefox browser installation impression notes clipping
C # Development -- pit encountered in JS intermodulation
Dbsync adds support for mongodb and ES
Common verification rules of form components -2 (continuously updating ~)
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
Vs custom template - take the custom class template as an example
Cataloger integrates lidar and IMU for 2D mapping
Record problems fgui tween animation will be inexplicably killed
Remember that a development is encountered in the pit of origin string sorting
Matplotlib快速入门
Yarn cannot view the historical task log of yarn after enabling ACL user authentication. Solution
Crawler (17) - Interview (2) | crawler interview question bank
微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
PHP method of obtaining image information
The PHP source code of the new website + remove authorization / support burning goose instead of pumping
[open source] Net ORM accessing Firebird database
Revit secondary development - get the project file path
Two methods of calling WCF service by C #
How to write an augmented matrix into TXT file
JS number is insufficient, and 0 is added