当前位置:网站首页>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;
// }
// }边栏推荐
- [web page performance optimization] what about the slow loading speed of the first screen of SPA (single page application)?
- Could not stop Cortex-M device! please check the JTAG cable的解决办法
- Oracle导入出错:IMP-00038: 无法转换为环境字符集句柄
- Repair process of bad blocks of primary standby database
- What are the advantages of real-time cloud rendering
- MySQL 索引优化全攻略
- Keil5 “Loading PDSC Debug Description Failed for STMicroelectronics STM32Hxxxxxxx”解决办法
- "Digital security" alert NFT's seven Scams
- 文件基础知识
- 【网页性能优化】SPA(单页面应用)首屏加载速度慢怎么办?
猜你喜欢

Stm8s003f3 internal flash debugging

What are the advantages of real-time cloud rendering

"Jargon" | what kind of experience is it to efficiently deliver games with Devops?

pd.melt() vs reshape2::melt()

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

Design practice of Netease strictly selecting inventory center

The new version of 3dcat v2.1.3 has been released. You can't miss these three function updates!

LeetCode 101. 对称二叉树 && 100. 相同的树 && 572. 另一棵树的子树

想要做好软件测试,可以先了解AST、SCA和渗透测试

There was an error while marking a file for deletion
随机推荐
Problems faced by cloud XR and main application scenarios of cloud XR
[Huawei machine test real question] string matching
这是一张机器&深度学习代码速查表
Conversion between integer and string in C language
Leetcode 101. symmetric binary tree & 100. same tree & 572. Subtree of another tree
二叉树的相关操作
1--- electronic physical cognition
Tensor to img & imge to tensor (tensor conversion of pytorch)
Is it true that CITIC Securities' low commission account opening is free of 5? Is it safe
How to choose digital twin visualization platform
文件基础知识
The new version of 3dcat v2.1.3 has been released. You can't miss these three function updates!
Recommend a qinheng Bluetooth reference blog
There was an error while marking a file for deletion
Related operations of figure
Could not stop Cortex-M device! Please check the JTAG cable solution
Today's sleep quality record is 84 points
UnitTest框架应用
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
vim基本操作命令