Skip to content

Commit 7177ee6

Browse files
committed
Update: Linked List Cycle
1 parent 88a189c commit 7177ee6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

problems/linked-list-cycle/linked_list_cycle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import . "github.com/openset/leetcode/internal/kit"
1111
*/
1212
func hasCycle(head *ListNode) bool {
1313
for p1, p2 := head, head; p1 != nil && p2 != nil; p1 = p1.Next {
14-
if p2.Next != nil {
15-
if p2 = p2.Next.Next; p1 == p2 {
14+
if p2 = p2.Next; p2 != nil {
15+
if p2 = p2.Next; p1 == p2 {
1616
return true
1717
}
1818
}

0 commit comments

Comments
 (0)