当前位置:网站首页>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 .
边栏推荐
- 1180: fractional line delimitation /p1068 [noip2009 popularization group] fractional line delimitation
- 线程和进程
- PMP考试重点总结九——收尾
- Stock suspension
- ==和eqauls()的区别
- 小米旗下支付公司被罚 12 万,涉违规开立支付账户等:雷军为法定代表人,产品包括 MIUI 钱包 App
- Understanding the IO model
- Implementation of single sign on
- 构造方法绝不是在new()之后就立马执行!!!!!
- PMP考试重点总结八——监控过程组(2)
猜你喜欢

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

Key summary V of PMP examination - execution process group

new URL(“www.jjj.com“)

Screen settings in the source code of OBS Live Room

new URL(“www.jjj.com“)

Data visualization makes correlation analysis easier to use

RMAN backup message ora-19809 ora-19804
Understanding the IO model

虚拟机14安装win7(图教程)

全局异常处理器与统一返回结果
随机推荐
Resource scheduling and task scheduling of spark
玩玩sftp上传文件
Importerror: no module named image [duplicate] - importerror: no module named image [duplicate]
Machine virtuelle 14 installer win7 (tutoriel)
Music website design based on harmonyos (portal page)
Interpretation of new products: realm launched GT neo2 Dragon Ball customized version
new URL(“www.jjj.com“)
SQL optimization experience: from 30248 seconds to 0.001 seconds
满电出发加速品牌焕新,长安电动电气化产品吹响“集结号”
PMP考试重点总结六——图表整理
Dbeaver连接人大金仓KingbaseES V8(超详细图文教程)
The private attribute of this class can be used directly? New() in use!!!
1182:合影效果
PMP考试重点总结五——执行过程组
PMP needs to master its own learning methods
Understanding the IO model
01-分布式系统概述
结巴分词器_分词器原理
全链路业务追踪落地实践方案
多线程-并发并行-线程进程