FastPrepPairs with Target Sum in a Sorted Array
Problems/Pairs with Target Sum in a Sorted Array

Pairs with Target Sum in a Sorted Array

Bank of America logoBank of America● EasyINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by two Bank of America candidates. An intern applicant got it as one of two easy coding tasks in a recorded video interview, and a new grad from a campus hiring drive was asked it in a later live technical round. The task was to pick out pairs from a sorted list; the live-round report adds that each pair must add up to a given number.

The reports give no examples, limits or output format. Here, the input is an array of up to 10,000 integers in sorted order, each pair of values is listed once with the smaller value first, and the pairs are ordered by their first value.

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

Given an integer array nums sorted in non-decreasing order and an integer target, return every pair of values [a, b] such that a + b == target and a and b come from two different positions of nums.

Write each pair with the smaller value first, so a <= b. List each pair of values only once, even if it can be formed from several positions, and order the pairs by a from smallest to largest. Return an empty list if there is no such pair.

Function

findPairs(nums: int[], target: int) → List<List<Integer>>

Examples

Example 1

nums = [1,2,3,4,4,6,7]target = 8return = [[1,7],[2,6],[4,4]]

1 + 7, 2 + 6 and 4 + 4 are 8. The pair [4,4] is allowed because 4 appears at two positions. 3 would need a 5, which is not in the array.

Example 2

nums = [-3,-1,0,2,2,5]target = 1return = [[-1,2]]

Only -1 + 2 is 1. The value 2 appears twice, but the pair [-1,2] is listed once.

Example 3

nums = [5]target = 10return = []

There is only one position, and a value cannot be paired with itself, so there is no pair.

Constraints

  • 1 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9
  • nums is sorted in non-decreasing order.
  • -2 * 10^9 <= target <= 2 * 10^9

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
  • Merge Point of Two Linked ListsOA · Seen Oct 2023
  • Remove Duplicates from a ListOA · 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

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Minimum Index Distance Between Person and CakeSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Meandering ArrayVerisk · OA
  • Interleave Array HalvesAutodesk · OAAutodesk interview questions
  • Collect Branches for a Bird NestVisa · OAVisa interview questions
  • Maximum Requests in a Time WindowIBM · OAIBM interview questions
  • Set IntersectionBlackRock · OABlackRock interview questions
  • Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
  • Filter Odds and Reverse EvensUpstart · OAUpstart interview questions
  • Score Difference When Even Picks Reverse the ListMicrosoft · OAMicrosoft 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 List<List<Integer>> findPairs(int[] nums, int target) {
        // write your code here
    }
}
Checking account…