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

66.67% Correct | 33.33% Incorrect
Last Solution submitted on Jan 08, 2026

Solution Comments

Show comments

Problem Recent Solvers8

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

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

Start Hunting!