My accepted solution


  • 0
    X
    class Solution:
        # @param head, a ListNode
        # @return a boolean
        def hasCycle(self, head):
        	if not head or not head.next:
        		return False
        	slow = fast = head
        	while fast and fast.next:
        		slow = slow.next
        		fast = fast.next.next
        		if slow == fast:
        			return True
        	return False

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.