FastPrepTwo Sum
Problems/Two Sum

Two Sum

Google logoGoogle● EasyINTERNFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Google SWE intern report names Two Sum in a live 45-minute technical interview. We rebuilt the formal limits, the guarantee of a unique solution, ascending index order, the function signature, and the examples. Our version is about 90% the same as the reported question.

Given an integer array nums and an integer target, return the two distinct indices whose values add up to target.

Exactly one valid pair exists. Return the smaller index first.

Function

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

Examples

Example 1

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

nums[0] + nums[1] = 2 + 7 = 9.

Example 2

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

nums[1] + nums[2] = 2 + 4 = 6.

Example 3

nums = [3,3]target = 6return = [0,1]

The two equal values occur at distinct indices.

Constraints

  • 2 <= nums.length <= 10000.
  • -1000000000 <= nums[i], target <= 1000000000.
  • Exactly one valid answer exists.

Source note: Author-written prompt excerpt retained for source fidelity.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Count Distinct Pairs With Sum KeBay · ONSITE INTERVIEWeBay interview questions
  • Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
  • Price CheckBlue Origin · PHONE SCREEN
  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Find Unique ElementsCisco · PHONE SCREENCisco interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Two SumAmazon · OA · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN

Interview reports that mention this question

  • Google SWE and PhD Intern Coding: 14 Experiences (Part 3 of 3)

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[] twoSum(int[] nums, int target) {
        // Write your code here.
    }
}
Checking account…