标签:return com lis cycle head fast null turn next
https://leetcode.com/problems/linked-list-cycle/#/description
do-while 的应用
public boolean hasCycle(ListNode head) { if (head == null) { return false; } ListNode fast = head; ListNode slow = head; do { if (fast == null || fast.next == null) { return false; } fast = fast.next.next; slow = slow.next; } while (fast != slow); if (slow == fast) { return true; } else { return false; } }
标签:return com lis cycle head fast null turn next
原文地址:http://www.cnblogs.com/apanda009/p/7123224.html