当前位置:网站首页>NC78 反转链表
NC78 反转链表
2022-07-25 18:13:00 【syc596】
NC78 反转链表
JZ24 反转链表
//11
//迭代
import java.util.*;
public class Solution {
public ListNode ReverseList(ListNode head) {
if(head==null||head.next==null){
return head;
}
ListNode prev=null;
ListNode cur=head;
while(cur!=null){
ListNode next=cur.next;
cur.next=prev;
prev=cur;
cur=next;
}
return prev;
}
}
// //递归
// import java.util.*;
// public class Solution {
// public ListNode ReverseList(ListNode head) {
// //递归结束条件
// if(head==null||head.next==null){
// return head;
// }
// ListNode vhead=ReverseList(head.next);
// //逆转本级节点
// head.next.next=head;
// //尾节点置空
// head.next=null;
// return vhead;
// }
// }边栏推荐
- Imx6 rtl8189ftv migration
- 数二2010真题考点
- TESTNG中的并发测试invocationCount, threadPoolSize, timeOut的使用
- Sequential storage structure, chain storage structure and implementation of stack
- SDLC software development life cycle and model
- 越来越成熟的Rust,都应用了哪些场景呢?
- Oracle import error: imp-00038: unable to convert to environment character set handle
- Postman get started quickly
- STM32F105RBT6 内部flash调试
- MySQL 索引优化全攻略
猜你喜欢

实时云渲染有哪些优势

Why the future of digitalization depends on 3D real-time rendering

超全Mavan标签详解

网易严选库存中心设计实践
![[MySQL]数据库中的索引为什么是用B+树来实现? 哈希表/红黑树/B树是否可行呢?](/img/1f/a2d50ec6bc97d52c1e7566a42e564b.png)
[MySQL]数据库中的索引为什么是用B+树来实现? 哈希表/红黑树/B树是否可行呢?

What is the relationship between cloud fluidization and cloud desktop

Tme2022 campus recruitment background development / operation development / business operation and maintenance / application development written examination (I) a little self analysis of programming q

Pan domain name configuration method

Nineteen year old summary

"Digital security" alert NFT's seven Scams
随机推荐
C语言 整数与字符串的相互转换
Tkinter GUI address book management system
What scenarios have rust, which is becoming more and more mature, applied?
Landmark buildings around the world
TME2022校园招聘后台开发/运营开发/业务运维/应用开发笔试(I)编程题的一点自我分析
Oracle导入出错:IMP-00038: 无法转换为环境字符集句柄
How to read a Book
SLA 、SLO & SLI
Use of C language cjson Library
SQL optimizer parsing | youth training camp notes
List转换问题
Basic knowledge of software testing (mind mapping)
对角化、A的幂
How to choose digital twin visualization platform
Basic operation of bidirectional linked list
更新|3DCAT实时云渲染 v2.1.2版本全新发布
Ch582 ble 5.0 uses Le coded broadcast and connection
nodejs 简单例子程序之express
408 Chapter 2 linear table
Talking about Devops monitoring, how does the team choose monitoring tools?