当前位置:网站首页>#yyds dry goods inventory# Interview must brush TOP101: the last k nodes in the linked list
#yyds dry goods inventory# Interview must brush TOP101: the last k nodes in the linked list
2022-08-01 18:52:00 【51CTO】
1.简述:
输入一个长度为 n 的链表,设链表中的元素的值为 ai ,返回该链表中倒数第k个节点.
如果该链表长度小于k,请返回一个长度为 0 的链表.
数据范围:,
,
要求:空间复杂度 ,时间复杂度
进阶:空间复杂度 ,时间复杂度
例如输入{1,2,3,4,5},2时,对应的链表结构如下图所示:
其中蓝色部分为该链表的最后2个结点,所以返回倒数第2个结点(也即结点值为4的结点)即可,系统会打印后面所有的节点来比较.
输入:
返回值:
说明:
输入:
返回值:
2.代码实现:
边栏推荐
- ACID Characteristics and Implementation Methods of MySQL Relational Database Transactions
- 日志工厂(详细)
- el-form-item prop属性动态绑定不生效如何解决
- 在Map传值与对象传值中模糊查询
- MySQL关系型数据库事务的ACID特性与实现方法
- shell脚本专题(07):文件由cfs到bos
- log factory (detail)
- 亚马逊云科技Build On2022技能提升计划第二季——揭秘出海爆款新物种背后的黑科技
- MySQL中超键、主键及候选键的区别是什么
- C#/VB.NET: extracted from the PDF document all form
猜你喜欢
483-82(23、239、450、113)
【神经网络】一文带你轻松解析神经网络(附实例恶搞女友)
Solve the problem that MySQL cannot insert Chinese data
PanGu-Coder:函数级的代码生成模型
What is the JVM runtime data area and the JMM memory model
OpenCV installation, QT, VS configuration project settings
30分钟成为Contributor|如何多方位参与OpenHarmony开源贡献?
在全志V853开发板试编译QT测试
Leetcode71. 简化路径
【木棉花】#夏日挑战赛# 鸿蒙小游戏项目——数独Sudoku(3)
随机推荐
Tower Defense Shoreline User Agreement
想随时、随地、随心使用数据库的朋友们,全体注意!
如何记录分析你的炼丹流程—可视化神器Wandb使用笔记【1】
顺序表的简单描述及代码的简单实现
【无标题】setInterval和setTimeout详解
MySQL中超键、主键及候选键的区别是什么
MySQL数据库————流程控制
1065 A+B and C (64bit)
The function realization of the national standard GB28181 protocol EasyGBS platform compatible with the old version of the inflow port
打开微信客服
Selenium在远程中的截图
SQL函数 TO_DATE(二)
Stop using MySQL online DDL
typora操作手册
生命周期和作用域
金鱼哥RHCA回忆录:CL210管理OPENSTACK网络--章节实验
What is the implementation principle of Go iota keyword and enumeration type
Three solutions: npm WARN config global --global, --local are deprecated. Use --location=global instead.
Summer vacation first week wrap-up blog
Live chat system technology (8) : vivo live IM message module architecture practice in the system