2014年3月18日

Linked List Cycle II

摘要: 1 ListNode *detectCycle(ListNode *head) { 2 if(!head||!head->next) 3 return NULL; 4 ListNode *fast,*slow; 5 fast=head; 6 slow=head; 7 while(fast&&fast->next) 8 { 9 slow=slow->next;10 fast=fast->next->next;11 ... 阅读全文

posted @ 2014-03-18 21:20 crane_practice 阅读(108) 评论(0) 推荐(0) 编辑

Linked List Cycle

摘要: 1 bool hasCycle(ListNode *head) { 2 if(head==NULL) 3 return false; 4 ListNode *pBefore,*pLater; 5 if(head->next) 6 pBefore=head->next; 7 else 8 return false; 9 pLater=head;10 while(pBefore)11 {12 ... 阅读全文

posted @ 2014-03-18 17:29 crane_practice 阅读(535) 评论(0) 推荐(0) 编辑

导航