FastPrepDisjoint Target-Sum Triplets
Problems/Disjoint Target-Sum Triplets

Disjoint Target-Sum Triplets

American Express logoAmerican Express● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an American Express full-time phone screen. The report gives the goal of finding triplets that add up to a target, and a rule that no value can be used twice anywhere. It does not give the finite input, what unique means, or the order for picking when triplets overlap. Our version is about 80% the same as the reported question.

You are given an integer array nums, representing a finite stream of integers, and an integer target.

A candidate triplet is a value triplet [a, b, c] such that a <= b <= c, a + b + c = target, and nums contains enough occurrences of its values.

Consider all distinct candidate triplets in lexicographic order. Starting with the full multiset of input occurrences, accept a candidate if all of its required occurrences are still available, then consume those occurrences. Otherwise skip it. Return the accepted triplets in that order.

Each value triplet can appear at most once, and no input occurrence can be used by more than one returned triplet.

Function

disjointTargetTriplets(nums: int[], target: int) → int[][]

Examples

Example 1

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

The first candidate is [0,1,5], so it is accepted and those occurrences are consumed. Every later candidate summing to 6 needs either 0 or 1, so it is skipped.

Example 2

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

[2,2,2] is the only distinct value triplet. It is returned once even though another three occurrences remain.

Example 3

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

The lexicographically first candidate consumes -4, one -1, and 5. The later candidate [-1,0,1] can use the remaining -1.

Constraints

  • 1 <= nums.length <= 2000.
  • -10^9 <= nums[i] <= 10^9.
  • -10^9 <= target <= 10^9.
  • Use sufficiently wide arithmetic when computing a complement or sum.

More American Express interview questions

  • Maximum Points in a Perimeter-Bounded RectangleOA · Seen Sep 2026
  • Minimum Moves to Spread Stones Across a GridOA · Seen Sep 2026
  • Largest Two Non-Overlapping Buildable SquaresOA · Seen Aug 2026
  • Maximum Sum of Two Sign-Flipping WindowsOA · Seen Aug 2026
  • Crop Text at a Whole-Word BoundaryOA · Seen Aug 2026
  • Minimum Parking Roof LengthOA · Seen Aug 2026
  • Minimum Pile Reduction StepsOA · Seen Aug 2026

Similar questions at other companies

  • Efficient TeamsExpedia · OAExpedia interview questions
  • Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions
  • Two SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
All American Express interview questionsSee American Express hiring insights
Saved
class Solution {
    public int[][] disjointTargetTriplets(int[] nums, int target) {
        // write your code here
    }
}
Checking account…