def detectCycle(head):
if head is None:
return None
tmp = {}
# index = 0
while head :
# tmp[head] = index
head = head.next
# index += 1
if head in tmp:
return head # return tmp[head] 如果返回的是索引
return None
142_环形链表Ⅱ
最新推荐文章于 2022-09-03 16:30:59 发布