File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
zh-hans/basics_data_structure Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -218,3 +218,39 @@ class NodeCircle:
218
218
else :
219
219
return False
220
220
```
221
+ ``` c++: is a circle
222
+ class List
223
+ {
224
+ public:
225
+ bool iscircle(ListNode* head)
226
+ {
227
+ if (!head || !head->next) return false;
228
+ ListNode *low = head, *fast = high;
229
+ while(fast && fast->next)
230
+ {
231
+ low = low->next;
232
+ fast = fast->next->next;
233
+ if (low == fast) return true;
234
+ }
235
+ return false;
236
+ }
237
+ };
238
+ ```
239
+
240
+ ``` c++
241
+ class List
242
+ {
243
+ public:
244
+ ListNode* InLisNodet(ListNode * head)
245
+ {
246
+ if (!head || !head->next) return head;
247
+ ListNode * low = head, * fast = head;
248
+ while(fast && fast->next)
249
+ {
250
+ low = low->next;
251
+ fast = fast->next->next;
252
+ }
253
+ return low;
254
+ }
255
+ };
256
+ ```
You can’t perform that action at this time.
0 commit comments