publicclassIntersectionofTwoLinkedLists{ public ListNode getIntersectionNode(ListNode headA, ListNode headB){ ListNode a = headA; ListNode b = headB; while (a.next != null && b.next != null) { a = a.next; b = b.next; if (a == b) return a; if (a.next == null) a = headB; if (b.next == null) b = headA; } returnnull; } }