虽然是一道Easy,但有一种解法太秒了,双指针的运用,特此搜集,原链接点这里
public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { ListNode A = headA, B = headB; while (A != B) { A = A != null ? A.next : headB; B = B != null ? B.next : headA; } return A; } }
链表类的题目通用思路:
…持续更新…