【剑指offer】链表中环的入口结点(python)
- p=pHead,复制一份链表
- python列表可以直接用 for i in list,其中 i 就是列表中的元素,不一定非要遍历索引
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def EntryNodeOfLoop(self, pHead): # write code here List = [] p = pHead while p: if p in List: return p else: List.append(p) p = p.next