当前位置:网站首页>Reverse linked list exercise
Reverse linked list exercise
2022-04-23 08:05:00 【Pen drawing Acacia】
var reverseList = function(head) {
// Judge the variable boundary problem
if (!head || !head.next) return head
// The initial setting is empty , Because after the first node is reversed, it is the tail , The tail node points to null
let pre = null
let current = head
let next
// Determine whether the current node is empty
// If it is not empty, get the next node of the current node first
// And then put the next Set as previous node
// And then put current Set as next node ,pre Set as current node
while(current) {
next = current.next
current.next = pre
pre = current
current = next
}
return pre
};
版权声明
本文为[Pen drawing Acacia]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230624332722.html
边栏推荐
- Cloud computing skills competition -- the first part of openstack private cloud environment
- 巨头押注的全屋智能,正在驱动海信、华为、小米们「自我革命」
- Alibaba sentinel学习QA
- 内网渗透系列:内网隧道之pingtunnel
- 输入 “ net start mysql ”,出现 “ 发生系统错误 5。 拒绝访问 ” 。问题详解
- SAP sto with billing process and configuration
- [programming practice / embedded competition] learning record of embedded competition (I): establishment of TCP server and web interface
- 云计算技能大赛 -- openstack私有云环境 第二部分
- feign如何集成hystrix
- 从零开始完整学习机器学习和深度学习,包括理论和代码实现,主要用到scikit和MXNet,还有一些实践(kaggle上的)
猜你喜欢
Export all SVG files in the specified path into pictures in PNG format (thumbnail or original size)
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
利用sqlmap注入获取网址管理员账号密码
Redis--为什么字符串emstr的字符串长度是44字节上限?
Three minutes to teach you to use Houdini fluid > > to solve particle fluid droplets
《内网安全攻防:渗透测试实战指南》读书笔记(五):域内横向移动分析及防御
How does Apache Hudi accelerate traditional batch mode?
BUUCTF [极客大挑战 2019]EasySQL1
云计算技能大赛 -- openstack私有云环境 第二部分
数据库之MySQL——基础篇
随机推荐
从ES、MongoDB、Redis、RocketMQ出发谈分布式存储
Research on system and software security (3)
《内网安全攻防:渗透测试实战指南》读书笔记(四):权限提升分析及防御
攻防世界MISC刷题1-50
[极客大挑战 2019]Havefun1
C # control the camera, rotate and drag the observation script (similar to scenes observation mode)
The displayed amount of ABAP ALV is inconsistent with the exported amount
MySQL——第一章节(MySQL中的数据类型)
sentinel集成nacos动态更新数据原理
Feign源码分析
CSV Column Extract列提取
Ribbon启动流程
三星,再次“西征”
BUUCTF [极客大挑战 2019]EasySQL1
内网渗透系列:内网隧道之icmpsh
使用 Ingress 实现金丝雀发布
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
访问数据库的时候出现错误 Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.详解
Reading notes
《内网安全攻防:渗透测试实战指南》读书笔记(七):跨域攻击分析及防御