当前位置:网站首页>NC4 judge whether there is a ring in the linked list
NC4 judge whether there is a ring in the linked list
2022-07-22 20:12:00 【henujolly】
public class Solution {
public boolean hasCycle(ListNode head) {
ListNode fast = head;
ListNode slow = head;
while (fast != null && fast.next != null)
{
fast = fast.next.next;
slow = slow.next;
if (fast == slow)
{
return true;
}
}
return false;
}
}
边栏推荐
猜你喜欢
[reading notes] MySQL architecture and storage engine
Spark SQL built-in functions and custom functions UDF
ZCU102板上PS端的E2PROM读写(XIICPS)
记一次win10安装cupy的失败经历(附 cupy与numpy对比)
图的深度优先搜索和广度优先搜索
Matlab FFT参数设置研究
Open MySQL binlog log on Linux
ping: www.baidu.com: 未知的名称或服务原因分析
CNN的简单实现过程
AttributeError: module ‘tensorflow.keras. utils‘ has no attribute image_ dataset_ from_ Directory - solution
随机推荐
Elastic Search 学习入门之restful的高级查询操作(九)
Record the failure experience of installing cupy in win10 (with comparison between cupy and numpy)
if else优化
小鸟平台隐私政策
The difference between location.replace and location.href
Kotlin learning II: classes and objects
转载:缓存一致性(Cache Coherency)入门
WLAN,Wi-Fi和802.11三者之间的关系
How to clear localstorage data after closing the browser
NFT挖矿分红系统开发模式定制
【C】从内存出发理解C语言变量作用域与生命周期
2017年终总结
ES6用法
spark中使用Accumulator累加器使用和注意事项
pyplot. When using plot: userwarning: starting a Matplotlib GUI outside of the main thread will like fail
MySql分页
ld: framework not found Pods_XXX clang: error: linker command failed with exit code 1 (use -v to see
Flutter 2进阶(二):Flutter空安全
appsstore transporter上传的时候一直卡在正在验证问题
Use of JVM jstat (virtual machine statistics monitoring tool)