We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b5744e commit 46b5f5eCopy full SHA for 46b5f5e
animation-simulation/链表篇/leetcode141环形链表.md
@@ -38,6 +38,7 @@
38
39
**题目代码**
40
41
+Java Code:
42
```java
43
public class Solution {
44
public boolean hasCycle(ListNode head) {
@@ -56,3 +57,18 @@ public class Solution {
56
57
}
58
```
59
60
+JS Code:
61
+```javascript
62
+var hasCycle = function(head) {
63
+ let fast = head;
64
+ let slow = head;
65
+ while (fast && fast.next) {
66
+ fast = fast.next.next;
67
+ slow = slow.next;
68
+ if (fast === slow) {
69
+ return true;
70
+ }
71
72
+ return false;
73
+};
74
+```
0 commit comments