一個鏈表中包含環,請找出該鏈表的環的入口結點

方法一、用HashSet來解決 1 public ListNode EntryNodeOfLoop(ListNode pHead){ 2 HashSet<ListNode> hs = new HashSet<ListNode>(); 3 while(pHead!=null){ 4 if(!hs.add(pHead))//如果包含了,那麼這個就
相關文章
相關標籤/搜索