mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-07 01:44:56 +08:00
Removed unnecessary condition
This commit is contained in:
@ -19,7 +19,7 @@ type ListNode = structures.ListNode
|
|||||||
func hasCycle(head *ListNode) bool {
|
func hasCycle(head *ListNode) bool {
|
||||||
fast := head
|
fast := head
|
||||||
slow := head
|
slow := head
|
||||||
for slow != nil && fast != nil && fast.Next != nil {
|
for fast != nil && fast.Next != nil {
|
||||||
fast = fast.Next.Next
|
fast = fast.Next.Next
|
||||||
slow = slow.Next
|
slow = slow.Next
|
||||||
if fast == slow {
|
if fast == slow {
|
||||||
|
Reference in New Issue
Block a user