
141. Linked List Cycle
·
Algorithm
Linked List Cycle - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. Object id값과 집합을 이용한 풀이 class Solution: def hasCycle(self, head: ListNode) -> bool: id_set = set() cur = head while cur: if id(cur) not in id_set: id_set.add(id(cur)) else: return True cur = cur.next return False..