Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c902f28

Browse files
committed
Feat: 141
1 parent 8035e5a commit c902f28

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎problems/141-linked-list-cycle.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## 题目
2+
3+
4+
* 141. 环形链表
5+
6+
给定一个链表,判断链表中是否有环。
7+
8+
## 思路
9+
10+
11+
## 代码
12+
13+
```php
14+
class Solution {
15+
/**
16+
* @param ListNode $head
17+
* @return Boolean
18+
*/
19+
function hasCycle($head) {
20+
$fast = $head;
21+
$slow = $head;
22+
while($fast->next) {
23+
$slow = $slow->next;
24+
$fast = $fast->next->next;
25+
if ($slow == $fast) {
26+
return true;
27+
}
28+
}
29+
return false;
30+
}
31+
}
32+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /