正确的我就不说了。
为啥下面的解法不对?
/* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } } */ import java.util.*; public class Solution { //方案2:双指针 public ListNode EntryNodeOfLoop(ListNode pHead) { if(pHead==null||pHead.next==null||pHead.next.next==null) return null; ListNode fast = pHead.next.next; ListNode slow = pHead; while(true){ if(fast==slow){ fast = pHead; break; } if(fast.next==null||fast.next.next==null){ return null; } fast = fast.next.next; slow = slow.next; } while(fast!=slow){ fast = fast.next; slow = slow.next; } return fast; } }