FastPrepFind Two-Sum or Three-Sum Index Combinations
Problems/Find Two-Sum or Three-Sum Index Combinations

Find Two-Sum or Three-Sum Index Combinations

Google logoGoogle● MediumFULLTIMENEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The original report presents Two Sum followed by Three Sum, without a clear output format. Our version uses one parameter for the tuple size and returns index combinations in lexicographic order.

Given an integer array nums, an integer target, and tupleSize equal to 2 or 3, return every index combination whose values sum to target.

  • For tupleSize = 2, return every [i, j] with i < j and nums[i] + nums[j] = target.
  • For tupleSize = 3, return every [i, j, k] with i < j < k and nums[i] + nums[j] + nums[k] = target.

Each distinct index combination appears once, even when values repeat. Return combinations in lexicographic index order.

Function

findTargetIndexCombinations(nums: int[], target: int, tupleSize: int) → int[][]

Examples

Example 1

nums = [2,7,11,15]target = 9tupleSize = 2return = [[0,1]]

Indices 0 and 1 contain 2 and 7, which sum to 9.

Example 2

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

The repeated value -1 occurs at different indices, so all three distinct index triples are retained.

Example 3

nums = [0,0,0,0]target = 0tupleSize = 2return = [[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]

All six pairs of different indices are valid and appear in lexicographic order.

Constraints

  • 2 <= nums.length <= 200
  • -1000000 <= nums[i], target <= 1000000
  • tupleSize is 2 or 3 and does not exceed nums.length.
  • The number of returned combinations is at most 200000.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Sparse Vector Dot Product from TuplesMeta · ONSITE INTERVIEWMeta interview questions
  • Two SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Repeated Shortest Word Distance QueriesLinkedIn · PHONE SCREENLinkedIn interview questions
  • Merge Keyed 2D ArraysWhatNot · PHONE SCREENWhatNot interview questions
  • Disjoint Target-Sum TripletsAmerican Express · PHONE SCREENAmerican Express interview questions
  • Efficient TeamsExpedia · OAExpedia interview questions
  • Sparse Vector Dot ProductAnduril · PHONE SCREENAnduril interview questions
  • Unique Pairs in a 2D Matrix Summing to TargetAmazon · PHONE SCREEN

Interview reports that mention this question

  • Google New Grad R1 and NYC Onsite: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[][] findTargetIndexCombinations(int[] nums, int target, int tupleSize) {
        // Write your code here.
    }
}
Checking account…