Problem
给定一个整数数组 nums 和一个整数 target,返回两个数字的 indices,使它们相加等于 target。
每个输入保证恰好有一个解,且同一个元素不能使用两次。
Examples
示例 1
Input: nums = [2, 7, 11, 15], target = 9
Output: [0, 1]
示例 2
Input: nums = [3, 2, 4], target = 6
Output: [1, 2]
示例 3
Input: nums = [3, 3], target = 6
Output: [0, 1]
Constraints
-
nums.length -
nums[i] -
target - 恰好存在一个有效答案。