当前位置:网站首页>Sword finger offer | linked list transpose
Sword finger offer | linked list transpose
2022-06-28 09:35:00 【Minor Yapi】
Transpose linked list {1,2,3} -> {3,2,1}
Given the head node of a single linked list head, The length is n, After reversing the linked list , Return the header of the new linked list .
public class Solution{
public ListNode ReverseList(ListNode head){
if(head == null){
return null;
}
ListNode pre = null;
ListNode next = head.next;
while(head != null){
// Local inversion
head.next = pre;
// pre head All move forward one space
pre = head;
head = next;
// If head Not empty , resume log next
if(head !=null){
next = head.next;
}
}
// At the end of the list , here 1<--2<--3(pre) head = null;
return pre;
}
It's not too late for you to say spring , I'll be in zhenjiangnan .
边栏推荐
- Why does select * lead to low query efficiency?
- How to reduce the risk of project communication?
- Rman Backup Report Ora - 19809 Ora - 19804
- A strange execution plan. One table in the association query is not associated with any other tables
- Write a simple timeline
- Key summary VII of PMP examination - monitoring process group (1)
- Full link service tracking implementation scheme
- 手机炒股开户安不安全?
- 微信小程序开发日志
- Fastjason filter field
猜你喜欢

数字人行业爆发在即,市场格局几何?

硬盘基本知识(磁头、磁道、扇区、柱面)
![1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定](/img/1a/162b060a6498e58278b6ca50e4953c.png)
1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定

学习阿里如何进行数据指标体系的治理

DolphinScheduler使用系统时间

File operations in QT

PMP Exam key summary VI - chart arrangement

RMAN backup message ora-19809 ora-19804

This article explains in detail the difficult problems and solutions faced by 3D cameras

Illustration of MySQL binlog, redo log and undo log
随机推荐
SQL injection file read / write
For the development of short video app, the elder warned me to choose the open source code
Fastjason filter field
微信小程序开发日志
1182: group photo effect
Edit the live broadcast source code with me. How to write the live broadcast app code
Which occupational groups are suitable for the examination
异常处理4种方法
静态代码块永远先执行? 格局小了!!!
自动转换之-面试题
Multithreading concurrent parallel threaded process
为什么SELECT * 会导致查询效率低?
How to reduce the risk of project communication?
1181: integer parity sort
玩玩sftp上传文件
浅谈小程序对传媒行业数字化的影响
Explain final, finally, and finalize
PMP考试重点总结七——监控过程组(1)
new URL(“www.jjj.com“)
PMP Exam key summary VI - chart arrangement