My accepted solution

  • 0
    class Solution:
        # @param head, a ListNode
        # @return a boolean
        def hasCycle(self, head):
        	if not head or not
        		return False
        	slow = fast = head
        	while fast and
        		slow =
        		fast =
        		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.