public ListNode getIntersectionNode(ListNode headA, ListNode headB) { if (headA == null || headB == null) { return null; } ListNode node1 = headA, node2 = headB; while (node1 != node2) { node1 = node1 != null ? node1.next : headB; node2 = node2 != null ? node2.next : headA; } return node1; }
是在是奇妙
不是自己做出来的