Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. def hasCycle(self, head):
  2.  
  3. if head==None or head.next==None:
  4. return False
  5.  
  6. ListNode.visited = False
  7.  
  8. while head != None:
  9.  
  10. if head.visited == True:
  11. return True
  12.  
  13. head.visited = True
  14. head = head.next
  15.  
  16. return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement