当前位置:网站首页>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;
}
};
边栏推荐
- Debezium系列之:源码阅读之BinlogReader
- Revit secondary development - cut view
- Robot autonomous exploration DSVP: code parsing
- Understand the autograd package in pytorch
- Revit secondary development - link file collision detection
- Add get disabled for RC form
- Visual design form QT designer design gui single form program
- Revit secondary development - wall opening
- 客户案例|华律网,通过观测云大幅缩短故障定位时间
- Record problems fgui tween animation will be inexplicably killed
猜你喜欢
PKPM 2020软件安装包下载及安装教程
Redis official ORM framework is more elegant than redistemplate
Antd date component appears in English
ByteDance Android interview, summary of knowledge points + analysis of interview questions
Visual design form QT designer design gui single form program
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
operator
. Net automapper use
[azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
Paint basic graphics with custompaint
随机推荐
Install mxnet GPU version
0-5vac to 4-20mA AC current isolated transmitter / conversion module
JS number is insufficient, and 0 is added
Revit secondary development - operation family documents
php 记录完整对接腾讯云直播以及im直播群聊 所遇到的坑
Main functions of OS, Sys and random Standard Libraries
[advanced MySQL] index details (I): index data page structure
OpenGL configure assimp
null == undefined
使用 CustomPaint 绘制基本图形
How to realize the movement control of characters in horizontal game
Cataloger integrates lidar and IMU for 2D mapping
The essence of analog Servlet
Unity local coordinates and world coordinates
Remove the default background color of chrome input input box
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
The strongest installation of the twin tower model, Google is playing "antique" again?
[problem] pytorch installation
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
Revit secondary development - Hide occlusion elements