当前位置:网站首页>[C题目]力扣141. 环形链表
[C题目]力扣141. 环形链表
2022-08-02 20:33:00 【GLC8866】
思路:快慢指针,同一起点,速度不同,出发以后两个指针如果相遇说明有环。
这里的相遇不是指第一次fast超过slow,而是指fast==slow。也就是说也可能存在fast超过slow,但是两结点未重合。
快慢指针一定会重合的原理:
bool hasCycle(struct ListNode *head)
{
struct ListNode * slow=head;
struct ListNode * fast=head;
while(fast&&fast->next)
{
slow=slow->next;
fast=fast->next->next;
if(fast==slow)
return true;
}
return false;
}边栏推荐
- 模糊查询like用法实例(Bee)
- The Orsay in Informatics (1256: Bouquet for Algernon)
- setup语法糖 defineProps defineEmits defineExpose
- 如何成为一名正义黑客?你应该学习什么?
- The time series database has been developed for 5 years. What problem does it need to solve?
- Likou Question of the Day - Day 46 - 344. Reverse Strings
- 广东省数字经济发展指引 1.0之建成数据安全保障体系
- 交 叉 数 组
- 千人优学 | GBase 8s数据库2022年6月大学生专场实训圆满结束
- 解道6-编程技术3
猜你喜欢

WPF development through practical 】 【 automatic production management platform

Li Mu hands-on deep learning V2-BERT pre-training and code implementation

你是几星测试/开发程序员?技术型选手王大拿......

Flink Yarn Per Job - 启动AM

框架设计:PC 端单页多页框架如何设计与落地

go——内存分配机制
Solve the docker mysql can't write Chinese

典型相关分析CCA计算过程

callback prototype __proto__

【目标检测】YOLOv5:640与1280分辨率效果对比
随机推荐
KDD 2022 | 深度图神经网络中的特征过相关:一个新视角
Flink Yarn Per Job - 启动AM
Informatics Olympiad All-in-One (1260: [Example 9.4] Intercepting Missiles (Noip1999))
Digital twins help visualize the construction of smart cities
C# Barrier类
【3D视觉】realsense D435三维重建
【21天学习挑战赛】冒泡排序与插入排序
Golang source code analysis: time/rate
李沐动手学深度学习V2-bert和代码实现
setup语法糖 defineProps defineEmits defineExpose
ABAP grammar small review
arm64麒麟安装paddlehub(国产化)
广东省数字经济发展指引 1.0之建成数据安全保障体系
C# Monitor class
如何理解 swing 是非线程安全 (原创)
一次线上事故,我顿悟了异步的精髓
Xcode13.1 run engineering error fatal error: 'IFlyMSC/IFly h' file not found
STP生成树协议
华为设备配置BFD多跳检测
汉源高科千兆4光4电工业级网管型智能环网冗余以太网交换机防浪涌防雷导轨式安装