当前位置:网站首页>Nc78 reverse linked list
Nc78 reverse linked list
2022-07-25 18:23:00 【syc596】
NC78 Reverse a linked list
Reverse a linked list _ Niuke Tiba _ Cattle from (nowcoder.com)
JZ24 Reverse a linked list
Reverse a linked list _ Niuke Tiba _ Cattle from (nowcoder.com)
//11
// iteration
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;
}
}
// // recursive
// import java.util.*;
// public class Solution {
// public ListNode ReverseList(ListNode head) {
// // Recursion end condition
// if(head==null||head.next==null){
// return head;
// }
// ListNode vhead=ReverseList(head.next);
// // Reverse current level node
// head.next.next=head;
// // The tail node is empty
// head.next=null;
// return vhead;
// }
// }边栏推荐
- 浅析回归问题、建模、预测
- List转换问题
- What are the advantages of real-time cloud rendering
- OV7725 yuv 640* [email protected] Profile
- Optimistic lock pessimistic lock applicable scenario
- 国际权威认可!OceanBase入选Forrester Translytical数据平台报告
- "Jargon" | what kind of experience is it to efficiently deliver games with Devops?
- Stm8s003f3 internal flash debugging
- Tang's little helper
- 对角化、A的幂
猜你喜欢

Oracle使用impdp导入报错:ORA-39001: 参数值无效 ORA-39000: 转储文件说明错误 ORA-39088: 文件名不能包含路径说明

ORB_SLAM3复现——上篇

Stm8s003f3 internal flash debugging

解决You can change this value on the server by setting the ‘max_allowed_packet‘ variable报错

408第二章线性表

7. 依赖注入

Design practice of Netease strictly selecting inventory center

How to choose digital twin visualization platform

Related operations of binary tree

imx6 RTL8189FTV移植
随机推荐
Application of current probe in ECU and electrical system current measurement
JZ32 从上往下打印二叉树
Error when starting MySQL on Linux
一次备库的坏块的修复过程
c语言---25 扫雷游戏
想要做好软件测试,可以先了解AST、SCA和渗透测试
Express of nodejs simple example program
Li Kai: the interesting and cutting-edge audio and video industry has always attracted me
Could not stop Cortex-M device! Please check the JTAG cable solution
STM8S003F3 内部flash调试
TESTNG中的并发测试invocationCount, threadPoolSize, timeOut的使用
11.1-CM24 最近公共祖先
Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%
[Huawei machine test real question] string matching
Compilation of program
Keil5 “Loading PDSC Debug Description Failed for STMicroelectronics STM32Hxxxxxxx”解决办法
二叉树的相关操作
"Digital security" alert NFT's seven Scams
Combined with GHS multi, use Reza E1 simulator to realize the simulation and debugging of Reza rh850 single chip microcomputer
Pan domain name configuration method