当前位置:网站首页># # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
# # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
2022-07-30 22:54:00 【51CTO】
1.简述:
判断给定的链表中是否有环.如果有环则返回true,否则返回false.
数据范围:链表长度 ,链表中任意节点的值满足
要求:空间复杂度 ,时间复杂度
输入分为两部分,第一部分为链表,第二部分代表是否有环,然后将组成的head头结点传入到函数里面.-1代表无环,其它的数字代表有环,这些参数解释仅仅是为了方便读者自测调试.实际在编程时读入的是链表的头节点.
例如输入{3,2,0,-4},1时,对应的链表结构如下图所示:

可以看出环的入口结点为从头结点开始的第1个结点(注:头结点为第0个结点),所以输出true.
输入:
复制
返回值:
复制
说明:
输入:
返回值:
说明:
输入:
返回值:
2.代码实现:
边栏推荐
猜你喜欢

Ningbo Zhongning Pawn will transfer 29.5% of the equity for 2.8338 million yuan, and the owner's equity in 2021 will be 9.6875 million yuan

可视化工具Netron介绍

Compressing Deep Graph Neural Networks via Adversarial Knowledge Distillation

MySQL联合查询(多表查询)

连号区间数

【Untitled】

When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'

Abstract classes and interfaces (study notes)

【无标题】

通过社交媒体建立个人IP的 5 种行之有效的策略
随机推荐
d使用among的问题
2022.7.27
Regular expression syntax and usage
grub 学习
IDEA 连接 数据库
“蔚来杯“2022牛客暑期多校训练营4 L.Black Hole 垃圾计算几何
# Dasctf 7月赋能赛 WP
DFS题单以及模板汇总
The most complete Redis basic + advanced project combat summary notes in history
Collapse legacy apps
ML之shap:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用RF随机森林+计算SHAP值单样本力图/依赖关系贡献图可视化实现可解释性之攻略
mysql获取当前时间
【Summary】机器人方法汇总
QT开发简介、命名规范、signal&slot信号槽
PS基础学习(一)
mysql跨库关联查询(dblink)
ML's shap: Based on FIFA 2018 Statistics (2018 Russia World Cup) team match star classification prediction data set using RF random forest + calculating SHAP value single-sample force map/dependency c
Detailed operator
Mysql进阶优化篇01——四万字详解数据库性能分析工具(深入、全面、详细,收藏备用)
$\text{ARC 145}$