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 9f6c787 commit 0a69fdeCopy full SHA for 0a69fde
List/Linked List CycleI
@@ -0,0 +1,35 @@
1
+ // 设置两个指针一块一慢
2
+ class Solution {
3
+ public:
4
+ bool hasCycle(ListNode *head) {
5
+ ListNode *slow = head,*fast = head;
6
+ while (slow && fast->next)
7
+ {
8
+ slow = slow->next;
9
+ fast = fast->next->next;
10
+ if(slow = fast)
11
+ return true;
12
+ }
13
+ return false;
14
+
15
16
17
+ };
18
+// 自己的方法。。。更改了原来的数据表。。所以。。有点不完美
19
20
21
22
+ ListNode *p = head;
23
+ while (p)
24
25
+ if(p->val != INT_MIN)
26
+ p->val = INT_MIN;
27
+ else
28
29
+ p = p->next;
30
31
32
33
34
35
0 commit comments