当前位置:网站首页>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 .
边栏推荐
- redis5.0的槽点迁移,随意玩(单机迁移集群)
- Fastjason filter field
- PMP needs to master its own learning methods
- File operations in QT
- 异常的产生,及解决
- I want to register my stock account online. How do I do it? Is online account opening safe?
- Redis5.0 slot migration, free play (single machine migration cluster)
- PMP考试重点总结九——收尾
- The digital human industry is about to break out. What is the market pattern?
- Prototype chain JS
猜你喜欢

Music website design based on harmonyos (portal page)

图解MySQL的binlog、redo log和undo log

PMP考试重点总结五——执行过程组

SQL 優化經曆:從 30248秒到 0.001秒的經曆

DEJA_ Vu3d - 051 of cesium function set - perfect realization of terrain excavation

SQL optimization experience: from 30248 seconds to 0.001 seconds

new URL(“www.jjj.com“)

基于宽表的数据建模

硬盘基本知识(磁头、磁道、扇区、柱面)

DBeaver安装与使用教程(超详细安装与使用教程)
随机推荐
线程和进程
剑指Offer | 链表转置
Ingersoll Rand面板维修IR英格索兰微电脑控制器维修XE-145M
JVM系列(2)——垃圾回收
Abnormal occurrence and solution
How to reduce the risk of project communication?
The constructor is never executed immediately after new()!!!!!
1181: integer parity sort
理解IO模型
小米旗下支付公司被罚 12 万,涉违规开立支付账户等:雷军为法定代表人,产品包括 MIUI 钱包 App
Fastjason filter field
PMP考试重点总结六——图表整理
1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定
手机买同业存单基金开户选哪家证券公司比较好,比较安全呢
Write a simple timeline
构造方法绝不是在new()之后就立马执行!!!!!
全链路业务追踪落地实践方案
Play SFTP upload file
SQL 優化經曆:從 30248秒到 0.001秒的經曆
函数的分文件编写