public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        int len1 = getLen(headA);
        int len2 = getLen(headB);
        if (len1 >= len2) {
            int diff = len1 - len2;
            while (diff-- > 0) {
                headA = headA.next;
            }
        } else {
            int diff = len2 - len1;
            while (diff-- > 0) {
                headB = headB.next;
            }
        }

        while (headA != null && headB != null) {
            if (headA == headB) {
                return headA;
            }
            headA = headA.next;
            headB = headB.next;
        }

        return null;
    }