摘要: 快慢指针: class Solution: def hasCycle(self, head: Optional[ListNode]) -> bool: # 如果链表为空或者只有一个节点,肯定不存在环 if not head or not head.next: return False # 初始化慢指 阅读全文
posted @ 2024-02-28 10:47 Junior_bond 阅读(5) 评论(0) 推荐(0)