当前位置:网站首页>JZ24 反转链表
JZ24 反转链表
2022-07-29 21:49:00 【syc596】
JZ24 反转链表
NC78 反转链表
//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;
// }
// }边栏推荐
- The world is on fire, Google servers have crashed
- install mysql using script
- 怎样下载国内外专利?
- 啊?现在初级测试招聘都要求会自动化了?
- Numpy array processing (2)
- Official announcement!Suzhou Wujiang Development Zone launches electronic labor contract platform
- GBASE 8s 如何查看 sbspace 中的可用空间
- 小程序预览pdf
- 百度智能云章淼:详解企业级七层负载均衡开源软件BFE
- 四、HikariCP源码分析之初始化分析一
猜你喜欢
随机推荐
SAP MIGO 报错-在例程WERT_SIMULIEREN字段NEUER_PREIS中字段溢出
Verilog 加法器设计
GBASE 8s 通过临时表提升排序性能
防火墙——SNAT和DNAT策略的原理及应用、防火墙规则的备份和还原
数组和List互转
获取七牛云地址文件保存到本地
小程序微信定位不准
qt中qstring合并字符串
【LeetCode】36、有效的数独
新库上线 | CnOpenData国际货运代理信息数据
Advanced Mathematics (Seventh Edition) Tongji University Exercises 3-8 Individual Answers
CNCF Keith Chan:分布式云时代,云原生社区的发展与趋势
GBASE 8s 自动删除正在被使用的数据库
七、HikariConfig初始化分析
Small program WeChat positioning is not accurate
GBASE 8s 如何估算索引使用多少空间
24-hour London gold chart analysis
【CVPR2022】A Unified Query-based Paradigm for Point Cloud Understanding
【板栗糖GIS】DOS—如何在目录文件中批量建立子文件夹
GBASE 8s 如何通过脚本获取bufwait等统计信息









