FastPrepMerge Point of Two Linked Lists
Problems/Merge Point of Two Linked Lists

Merge Point of Two Linked Lists

Bank of America logoBank of America● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by a Bank of America new grad from a campus drive, as one of two coding tasks in a recorded video interview, which the company counted as its written round. The candidate wrote the code and then recorded an explanation of it. The report names only the task: find where two linked lists join.

The report gives no input format, examples or limits. Here, both lists are stored in one array of next pointers, the answer is the index of the first shared node or -1 when the lists never meet, and there are at most 10,000 nodes.

Our version is about 80% the same as the reported question.

Two singly linked lists are stored together in one array next. The nodes are numbered from 0 to next.length - 1. Node i points to node next[i], and next[i] = -1 means node i is the last node of its list. The first list starts at node headA and the second list starts at node headB.

The two lists may merge: from some node on, both lists run through exactly the same nodes to the end. Return the index of the merge point, which is the first node that is on both lists. If no node is on both lists, return -1.

Nodes are told apart by their index. Every node in the array is on at least one of the two lists.

Function

findMergePoint(next: int[], headA: int, headB: int) → int

Examples

Example 1

next = [5,5,-1,1,0,2]headA = 4headB = 3return = 5

The first list visits nodes 4, 0, 5, 2 and the second list visits nodes 3, 1, 5, 2. Node 5 is the first node on both lists, and from there both lists go on to node 2.

Example 2

next = [2,3,4,-1,-1]headA = 0headB = 1return = -1

The first list is 0, 2, 4 and the second list is 1, 3. No node is on both lists, so the answer is -1.

Example 3

next = [3,-1,0,1]headA = 2headB = 3return = 3

The first list is 2, 0, 3, 1. The second list starts at node 3, which is already the third node of the first list, so the whole second list 3, 1 is shared and the merge point is 3.

Constraints

  • 1 <= next.length <= 10^4
  • -1 <= next[i] < next.length
  • 0 <= headA, headB < next.length
  • Following next from headA or from headB always ends at -1, so neither list has a cycle.
  • Every node is on at least one of the two lists.

More Bank of America Online Assessment questions

  • Return Exact Cash Register ChangeOA · Seen Aug 2026
  • Sum Skipping Multiples of 7OA · Seen Nov 2025
  • Wildcard Substring MatchOA · Seen Nov 2025
  • Maximum String BeautyOA · Seen Sep 2024
  • Remove Duplicates from a ListOA · Seen Oct 2023
  • Pairs with Target Sum in a Sorted ArrayOA · Seen Oct 2023
  • Count Level-Order Traversals of a TreeOA · Seen Sep 2023
  • Count Set BitsOA · Seen Sep 2023
  • Count Pairs with Sum KOA · Seen Jun 2023
  • Letter Pattern SumOA · Seen Sep 2022

Similar questions at other companies

  • First Node Two Linked Lists ShareAdobe · PHONE SCREENAdobe interview questions
  • Find Where Two Linked Lists MergeExpedia · ONSITE INTERVIEWExpedia interview questions
  • Where Two Linked Lists MeetNutanix · PHONE SCREENNutanix interview questions
  • Detect a Linked-List CyclePaytm · ONSITE INTERVIEWPaytm interview questions
  • Detect a Linked-List CycleCapgemini · ONSITE INTERVIEWCapgemini interview questions
  • Detect a Linked-List CycleMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Find the Intersection Node of Two Linked ListsConcentric AI · OAConcentric AI interview questions
  • Get Distinct Pairs (Also apply to AS intern)Amazon · OA
  • Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions
  • Merge Two Sorted ListsThe Walt Disney Company · OAThe Walt Disney Company interview questions

Bank of America interview experiences

  • Bank of America interviews · December 2025
  • Bank of America OA · December 2025
  • Bank of America interviews · September 2026
  • Bank of America OA · September 2026
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public int findMergePoint(int[] next, int headA, int headB) {
        // write your code here
    }
}
Checking account…