Skip to content

Commit 53973b6

Browse files
Update floyds_cycle_detection.py
1 parent b5e0cf8 commit 53973b6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

data_structures/linked_list/floyds_cycle_detection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def __iter__(self) -> Iterator:
4848
>>> tuple(linked_list)
4949
(1,)
5050
"""
51-
visited = set()
51+
visited = []
5252
node = self.head
5353
while node:
5454
# Avoid infinite loop in there's a cycle
5555
if node in visited:
5656
return
57-
visited.add(node)
57+
visited.append(node)
5858
yield node.data
5959
node = node.next_node
6060

0 commit comments

Comments
 (0)