You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
上面的我搞错了,正确应该是这样吧。。
def getloopmeet(head):
fast = head.next.next
slow = head.next
while fast != slow:
if fast == None or slow == None:
return None
fast = fast.next.next
slow = slow.next
fast = head
while fast != slow:
fast = fast.next
slow = slow.next
return fast
应该是:if fast == None or slow == None: 才返回None吧?
而且是返回return fast.next这个才是第一个进环的结点,直接返回fast是前一个结点
我写了测试发现的,楼主看下
3 <main.Node object at 0x000001E414C26080>
4 <main.Node object at 0x000001E414C260B8>
5 <main.Node object at 0x000001E414C26048>
3 <main.Node object at 0x000001E414C26080>
4 <main.Node object at 0x000001E414C260B8>
5 <main.Node object at 0x000001E414C26048>
3 <main.Node object at 0x000001E414C26080>
4 <main.Node object at 0x000001E414C260B8>
结果= <main.Node object at 0x000001E414C26080>
The text was updated successfully, but these errors were encountered: