FastPrepTarget Triplet Sum
Problems/Target Triplet Sum

Target Triplet Sum

Motive logoMotive● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Motive onsite report for a full-time role asks for a triplet that adds up to a target sum, using constant space. We chose what shape the answer takes, the limits, and whether you may reorder the input.

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

Given an integer array nums and an integer target, return whether three distinct indices have values whose sum equals target.

Your algorithm may reorder nums, but it must use only constant auxiliary space apart from the sorting implementation's call stack.

Function

hasTargetTriplet(nums: int[], target: int) → boolean

Examples

Example 1

nums = [12,3,4,1,6,9]target = 24return = true

The values 12, 3, and 9 sum to 24.

Example 2

nums = [1,2,4,8]target = 20return = false

No three distinct indices produce 20.

Constraints

  • 0 <= nums.length <= 100000.
  • -10^9 <= nums[i], target <= 10^9.

More Motive Onsite Interview questions

  • Group AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Longest Equal-Zero-One SubarrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Maximum Weighted Sum After Left RotationsONSITE INTERVIEW · Seen Jan 2026
  • Valid Parenthesis StringPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Dec 2025
  • Validate IP AddressONSITE INTERVIEW · Seen Dec 2025
  • Generate Palindromic PermutationsONSITE INTERVIEW · Seen Dec 2025
  • Minimum Swaps to Group Circular OnesONSITE INTERVIEW · Seen Dec 2025
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Dec 2025
  • Search in Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEWWhatNot interview questions
  • 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
All Motive interview questionsSee Motive hiring insights
Saved
class Solution {
    public boolean hasTargetTriplet(int[] nums, int target) {
        // Find three distinct values whose sum is target.
    }
}
Checking account…