本文共 256 字,大约阅读时间需要 1 分钟。
给一个链表,若其中包含环,请找出该链表的环的入口结点,否则,输出null。
class Solution: def EntryNodeOfLoop(self, pHead): list = [] p = pHead while p: if p in list: return p list.append(p) p = p.next
转载地址:http://ybfab.baihongyu.com/