Problem 61153. Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You must return smaller indices first.
Example:
Input: nums = [2,7,11,15], target = 9
Output: [1, 2]
Explanation: Because nums[1] + nums[2] == 9, we return [1, 2].

Solution Stats

61.9% Correct | 38.1% Incorrect
Last Solution submitted on Jan 21, 2026

Solution Comments

Show comments

Problem Recent Solvers11

Suggested Problems

More from this Author8

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!