daily algorithm 判断链表是否有环

  public static boolean isLoopLink(ListNode head) {
        if (head == null) {
            return false;
        }
        ListNode fast = head.next;
        ListNode slow = head;
        while (fast.next != null) {
            if (fast == slow) {
                return true;
            }
            fast = fast.next.next;
            slow = slow.next;
        }
        return false;
    }
原文地址:https://www.cnblogs.com/lijiale/p/10980135.html