MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / has_cycle

Function has_cycle

Hackerrank_problems/Cycle Detection/solution.py:39–50  ·  view source on GitHub ↗

Function implemented to identify the cycles in a linked list

(head)

Source from the content-addressed store, hash-verified

37 fptr.write(sep)
38
39def has_cycle(head):
40 """
41 Function implemented to identify the cycles in a linked list
42 """
43 slow = head
44 fast = head
45 while fast and fast.next:
46 slow = slow.next
47 fast = fast.next.next
48 if slow == fast: # Checks if the slow and fast pointers have been match into a cycle
49 return 1
50 return 0
51
52
53if __name__ == '__main__':

Callers 1

solution.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected