当前位置:网站首页>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;
}
};
边栏推荐
- Form组件常用校验规则-2(持续更新中~)
- Aspose. Word operation word document (I)
- 海外代理推荐
- #DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
- Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
- ASP. Net core introduction V
- OpenGL job - texture
- Record a garbled code during servlet learning
- PHP records the pitfalls encountered in the complete docking of Tencent cloud live broadcast and im live group chat
- [problem] pytorch installation
猜你喜欢

Remember an experience of using selectmany

How pyGame rotates pictures

Robot autonomous exploration DSVP: code parsing

OpenGL configuration vs2019

Signal feature extraction +lstm to realize gear reducer fault diagnosis -matlab code

operator

Common verification rules of form components -2 (continuously updating ~)

Micro service remote debug, nocalhost + rainbow micro service development second bullet
Apple further entered the financial sector through the 'virtual card' security function in IOS 16

Microservice Remote debug, nocalhost + rainbond microservice Development second Bomb
随机推荐
Details of the open source framework of microservice architecture
C # Development -- pit encountered in JS intermodulation
ASP. Net core introduction V
Pyqt GUI interface and logic separation
OpenGL configuration vs2019
如何实现横版游戏中角色的移动控制
OpenGL job coordinate system
Two kinds of updates lost and Solutions
The PHP source code of the new website + remove authorization / support burning goose instead of pumping
使用 CustomPaint 绘制基本图形
戴森官方直营店免费造型服务现已开放预约 先锋科技诠释护发造型理念,助力消费者解锁多元闪耀造型
Time standard library
使用 BlocConsumer 同时构建响应式组件和监听状态
反爬通杀神器
Ren Qian code compilation error modification
Micro service remote debug, nocalhost + rainbow micro service development second bullet
OpenGL job - texture
Remove the default background color of chrome input input box
What does it mean to prefix a string with F?
客户案例|华律网,通过观测云大幅缩短故障定位时间