From b18e3eaa146f1abd4b874d855ddbf224c5dbd287 Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Mon, 19 Oct 2026 21:51:42 +0900 Subject: [PATCH] Create 141. Linked List Cycle.py --- .../141. Linked List Cycle.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/141. Linked List Cycle.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/141. Linked List Cycle.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/141. Linked List Cycle.py" new file mode 100644 index 00000000..541eb739 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/141. Linked List Cycle.py" @@ -0,0 +1,18 @@ +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, x): +# self.val = x +# self.next = None + +class Solution: + def hasCycle(self, head: Optional[ListNode]) -> bool: + jump1 = head + jump2 = head + + while jump2 and jump2.next: + jump1 = jump1.next + jump2 = jump2.next.next + if jump1 == jump2: + return True + + return False