当前位置:网站首页># # 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.代码实现:
边栏推荐
- MySQL 8.0.29 decompressed version installation tutorial (valid for personal testing)
- Go1.18升级功能 - 模糊测试Fuzz 从零开始Go语言
- Debezium报错系列之二十:task failed to create new topic.Ensure that the task is authorized to create topics
- Apache Doris系列之:安装与部署详细步骤
- 2022.7.30
- Day016 Classes and Objects
- 【无标题】
- 正则表达式语法及使用
- PS基础学习(一)
- 成功解决ModuleNotFoundError: No module named ‘Image‘
猜你喜欢
使用LVS和Keepalived搭建高可用负载均衡服务器集群
反转链表-头插反转法
【Untitled】
PS基础学习(一)
Go语学习笔记 - gorm使用 - 事务操作 Web框架Gin(十一)
ThinkPHP high imitation blue play cloud network disk system source code / docking easy payment system program
Navicat cannot connect to mysql super detailed processing method
PhpMetrics 使用
Jetson AGX Orin 平台关于c240000 I2C总线和GMSL ses地址冲突问题
IDEA使用技巧
随机推荐
2022.7.27
【Summary】机器人方法汇总
Apache Doris系列之:安装与部署详细步骤
Excel基础学习笔记
OpenCV笔记(二十):滤波函数——filter2D
cnpm安装步骤
MySQL compressed package installation, fool teaching
HF2022-EzPHP复现
基于 Docker Compose 的 Nacos(MySQL 持久化)的搭建
Gxlcms audio novel system/novel listening system source code
grub 学习
proxy反向代理
PyTorch模型导出到ONNX文件示例(LeNet-5)
$\text{ARC 145}$
openim支持十万超级大群
MySQL 8.0.29 设置和修改默认密码
[MySQL] Related operations on databases and tables in MySQL
VS2017编译Tars测试工程
mysql去除重复数据
通过社交媒体建立个人IP的 5 种行之有效的策略