当前位置:网站首页>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
边栏推荐
- C smoothprogressbar custom progress bar control
- Feign source code analysis
- Ctf-misc learning from start to give up
- [unity VFX] Introduction notes of VFX special effects - spark production
- Analysis of Nacos source code
- Chapter VII asset impairment
- 《内网安全攻防:渗透测试实战指南》读书笔记(六):域控制器安全
- 内网渗透系列:内网隧道之dns2tcp
- SAP self created table log function is enabled
- Research on system and software security (4)
猜你喜欢

C # control the camera, rotate and drag the observation script (similar to scenes observation mode)

惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧

SAP tr manual import system operation manual

内网渗透系列:内网隧道之icmp_tran

内网渗透系列:内网隧道之icmptunnel(jamesbarlow师傅的)

Analysis of Nacos source code

Sto with billing cross company inventory dump return

内网渗透系列:内网隧道之pingtunnel

Chapter V investment real estate
![[unity VFX] Introduction notes of VFX special effects - spark production](/img/bb/a6c637d025dfb8877e6b85e7f39d6b.png)
[unity VFX] Introduction notes of VFX special effects - spark production
随机推荐
Analysis of Nacos source code
Complete learning from scratch, machine learning and deep learning, including theory and code implementation, mainly using scikit and mxnet, and some practices (on kaggle)
Expression related to month, year and day in SVG
第五章 投资性房地产
CTF-MISC总结
Research on system and software security (2)
MySQL--锁的奥秘--数据怎么锁
聊聊接口幂等与消费幂等的本质
Dvwa 靶场练习记录
三星,再次“西征”
Chapter IV intangible assets
SAP self created table log function is enabled
[problem solving] vs2019 solves the problem that the EXE file generated by compilation cannot be opened
C problem of marking the position of polygons surrounded by multiple rectangles
[unity VFX] Introduction notes of VFX special effects - spark production
Online Safe Trajectory Generation For Quadrotors Using Fast Marching Method and Bernstein Basis Poly
Learning records of some shooting ranges: sqli labs, upload labs, XSS
Guoji Beisheng openstack container cloud environment construction
《内网安全攻防:渗透测试实战指南》读书笔记(五):域内横向移动分析及防御
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP