当前位置:网站首页>#yyds干货盘点# 面试必刷TOP101: 链表中倒数最后k个结点
#yyds干货盘点# 面试必刷TOP101: 链表中倒数最后k个结点
2022-08-01 18:43:00 【51CTO】
1.简述:
输入一个长度为 n 的链表,设链表中的元素的值为 ai ,返回该链表中倒数第k个节点。
如果该链表长度小于k,请返回一个长度为 0 的链表。
数据范围:,
,
要求:空间复杂度 ,时间复杂度
进阶:空间复杂度 ,时间复杂度
例如输入{1,2,3,4,5},2时,对应的链表结构如下图所示:
其中蓝色部分为该链表的最后2个结点,所以返回倒数第2个结点(也即结点值为4的结点)即可,系统会打印后面所有的节点来比较。
输入:
返回值:
说明:
输入:
返回值:
2.代码实现:
边栏推荐
- ExcelPatternTool: Excel表格-数据库互导工具
- Detailed explanation of DBPack SQL Tracing function and data encryption function
- C#/VB.NET: extracted from the PDF document all form
- The life cycle and scope
- C language theory--a solid foundation for the written test and interview
- How to build a CMDB driven by consumption scenarios?
- SQL函数 TO_DATE(一)
- 【翻译】CNCF培养的OpenMetrics成为一个孵化项目
- 123123123123
- opencv如何实现图像倾斜校正
猜你喜欢
Leetcode73. Matrix Zeroing
B001 - Intelligent ecological fish tank based on STM32
Leetcode71. Simplified Paths
粒子滤波 particle filter —从贝叶斯滤波到粒子滤波——Part-I(贝叶斯滤波)
A simple Flask PIN
MySQL中超键、主键及候选键的区别是什么
How opencv implements image skew correction
How to build a CMDB driven by consumption scenarios?
C language theory--a solid foundation for the written test and interview
在Map传值与对象传值中模糊查询
随机推荐
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) Solution
基于flowable的upp(统一流程平台)运行性能优化
如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
Go GORM事务实例分析
No need to crack, install Visual Studio 2013 Community Edition on the official website
B005 - STC8 based single chip microcomputer intelligent street light control system
What is the implementation principle of Go iota keyword and enumeration type
Stop using MySQL online DDL
AntDB database appeared in the 24th high-speed exhibition, helping smart high-speed innovative applications
【Day_12 0507】二进制插入
Redis的内存淘汰策略和过期删除策略的区别是什么
【Error】Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘concat’)
Detailed explanation of DBPack SQL Tracing function and data encryption function
MySQL 45 Talk | 09 How to choose common index and unique index?
483-82(23、239、450、113)
【Day_10 0428】密码强度等级
安徽建筑大学&杭州电子科技大学|基于机器学习方法的建筑可再生能源优化控制
log factory (detail)
LeetCode 0151. Reverse a string of words
Leetcode75. Color Classification