FastPrepTwo Sum
Problems/Two Sum

Two Sum

The Walt Disney Company logoThe Walt Disney Company● EasyFULLTIMEOAPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The technical round asked: "two sum".

The report does not specify input bounds, pair guarantees, or output order. Here, exactly one pair exists, and its zero-based indices are returned in increasing order. The numeric bounds are practice choices.

The judged task matches the report at about 85%.

Given an integer array nums and an integer target, return the zero-based indices of the two numbers whose sum is target.

Use two different positions. Return the smaller index first. Exactly one valid pair exists.

Function

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

Examples

Example 1

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

The values at indices 0 and 1 are 2 and 7. Their sum is 9, so return [0,1].

Example 2

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

The values 2 and 4 sum to 6. They are at indices 1 and 2. The single value 3 cannot be used twice.

Constraints

  • 2 <= nums.length <= 2000
  • -1000000 <= nums[i] <= 1000000
  • -2000000 <= target <= 2000000
  • Exactly one pair of distinct indices sums to the target.

More The Walt Disney Company problems

  • Find All Paths for a Name in a File SystemPHONE SCREEN · Seen Nov 2026
  • Resizable Array-Backed Integer SetPHONE SCREEN · Seen Sep 2026
  • Shortest Path with Directional Move CostsPHONE SCREEN · Seen Sep 2026
All The Walt Disney Company interview questionsSee The Walt Disney Company hiring insights
Saved
class Solution {
    public int[] twoSum(int[] nums, int target) {
        // Write your code here
    }
}
Checking account…