FastPrepThree Numbers That Add Up to a Target
Problems/Three Numbers That Add Up to a Target

Three Numbers That Add Up to a Target

Bank of America logoBank of America● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by an experienced QA automation engineer who interviewed with Bank of America in the United States. The report lists the questions for the whole process without saying which round asked which; the only round it links to Python is the final hiring-manager round, which was technical. The task was to write Python code that picks three values in a list that together equal a given number.

The report gives no examples, limits or output format. Here, every set of three values with that total is returned once, in sorted order, and the list has 3 to 1,000 integers.

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

Given an integer array nums and an integer target, return every triplet of values [a, b, c] such that a + b + c == target and the three values come from three different positions of nums.

Write each triplet in non-decreasing order, so a <= b <= c. List each triplet of values only once, even if it can be formed from several sets of positions. Order the triplets by a, then by b, from smallest to largest. Return an empty list if there is no such triplet.

Function

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

Examples

Example 1

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

-2 + 3 + 4, 0 + 1 + 4 and 0 + 2 + 3 are all 5. No other set of three values adds up to 5. The triplets are ordered by their first value, then their second.

Example 2

nums = [2,2,2,2]target = 6return = [[2,2,2]]

Any three of the four 2s add up to 6. They all give the same values, so [2,2,2] is listed once.

Example 3

nums = [1,1,1]target = 4return = []

The only triplet adds up to 3, not 4, so the list is empty.

Constraints

  • 3 <= nums.length <= 1000
  • -10^5 <= nums[i] <= 10^5
  • -3 * 10^5 <= target <= 3 * 10^5

More Bank of America Onsite Interview questions

  • Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
  • Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
  • N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
  • Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
  • Second Highest SalaryONSITE INTERVIEW · Seen Nov 2025
  • Duplicate RowsONSITE INTERVIEW · Seen Oct 2023
  • Factorial of a NumberONSITE INTERVIEW · Seen Oct 2023
  • Palindrome String CheckONSITE INTERVIEW · Seen Sep 2023
  • Second Largest Element in an ArrayONSITE INTERVIEW · Seen Jun 2023

Similar questions at other companies

  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Minimum Station Tracks for a Train ScheduleBNSF Railway · ONSITE INTERVIEWBNSF Railway interview questions
  • 4SumAmazon · ONSITE INTERVIEW
  • Count Triplets With Sum at Most TargetGoogle · ONSITE INTERVIEWGoogle interview questions
  • Sort ColorsCapital One · ONSITE INTERVIEWCapital One interview questions
  • 3SumOptimus Information · ONSITE INTERVIEWOptimus Information interview questions
  • 3SumMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Next and Previous Lexicographic PermutationAdobe · ONSITE INTERVIEWAdobe interview questions
  • Sort ColorsInfosys · ONSITE INTERVIEWInfosys 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>> threeSumTarget(int[] nums, int target) {
        // write your code here
    }
}
Checking account…