Learnixo
Challenges

Two Sum

intermediate 150 XP

Problem

Given an array of integers and a target, return the indices of the two numbers that add up to the target. Each input has exactly one solution.

Test Cases

First two elements
Input: nums=[2,7,11,15], target=9
Expected: [0,1]
Non-adjacent elements
Input: nums=[3,2,4], target=6
Expected: [1,2]
Duplicate values
Input: nums=[3,3], target=6
Expected: [0,1]

Hints

AI Assistance