当前位置:网站首页>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 .
边栏推荐
- I want to register my stock account online. How do I do it? Is online account opening safe?
- 买卖股票费用计算
- Apache Doris 成为 Apache 顶级项目
- PMP examination key summary VIII - monitoring process group (2)
- Data modeling based on wide table
- A classic JVM class loaded interview question class singleton{static singleton instance = new singleton(); private singleton() {}
- [ybtoj advanced training guidance] class roll call [string hash]
- Linux下安装redis 、Windows下安装redis(超详细图文教程)
- 小米旗下支付公司被罚 12 万,涉违规开立支付账户等:雷军为法定代表人,产品包括 MIUI 钱包 App
- Do static code blocks always execute first? The pattern is smaller!!!
猜你喜欢

Why does select * lead to low query efficiency?

Interpretation of new products: realm launched GT neo2 Dragon Ball customized version

全局异常处理器与统一返回结果

Valentine's Day - VBS learning (sentences, love words)

Screen settings in the source code of OBS Live Room

Virtual machine 14 installing win7 (Figure tutorial)

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

Data mining modeling practice

RMAN backup message ora-19809 ora-19804

new URL(“www.jjj.com“)
随机推荐
布隆过滤器 课程研究报告
Multithreading concurrent parallel threaded process
优秀笔记软件盘点:好看且强大的可视化笔记软件、知识图谱工具Heptabase、氢图、Walling、Reflect、InfraNodus、TiddlyWiki
小米旗下支付公司被罚 12 万,涉违规开立支付账户等:雷军为法定代表人,产品包括 MIUI 钱包 App
基于宽表的数据建模
How to implement two factor authentication MFA based on RADIUS protocol?
Play SFTP upload file
Which securities company is better and safer to choose when opening an account for the inter-bank certificate of deposit fund with mobile phone
异常
Boundary value analysis method for learning basic content of software testing (2)
P2394 yyy loves Chemistry I
2020-10-27
1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定
数字人行业爆发在即,市场格局几何?
Linux下安装redis 、Windows下安装redis(超详细图文教程)
剑指Offer | 斐波那契数列
PMP examination key summary VIII - monitoring process group (2)
线程和进程
Custom exception classes and exercises
硬盘基本知识(磁头、磁道、扇区、柱面)