We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f548cf4 commit a075497Copy full SHA for a075497
1 file changed
linked-list-cycle/Seoya0512.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ def hasCycle(self, head: Optional[ListNode]) -> bool:
3
+ cycle_set = set()
4
+ while head:
5
+ if head in cycle_set:
6
+ return True
7
+ cycle_set.add(head)
8
+ head = head.next
9
+ return False
10
+
0 commit comments