Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Two Sum

XPChallenge Points: 10
levelLevel: Easy

You are 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 there is exactly one solution for each input.

·       You cannot use the same element twice.

·       The answer can be returned in any order.

Example 1:

Input: nums = [5, 1, 3, 7], target = 8

Output: [0, 2]

Explanation:

nums[0] + nums[2] = 5 + 3 = 8.

Example 2:

Input: nums = [10, 4, 8, 2], target = 12

Output: [1, 2]

Explanation:

nums[1] + nums[2] = 4 + 8 = 12.

Example 3:

Input: nums = [1, 5, 5], target = 10

Output: [1, 2]

Explanation:

nums[1] + nums[2] = 5 + 5 = 10.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result