-
-
Save vicxruiz/35de65476b4ae1a3db5017dbeff11b0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given an array of integers, return indices of the two numbers such that they add up to a specific target. | |
You may assume that each input would have exactly one solution, and you may not use the same element twice. | |
Example 1: | |
Given nums = [2, 7, 11, 15], target = 9, | |
Because nums[0] + nums[1] = 2 + 7 = 9, | |
return [0, 1]. | |
Example 2: | |
Given nums = [3,2,4], target = 6, | |
Expected: | |
[1,2] | |
Example 3: | |
Given nums = [3,3], target = 6 | |
Expected: | |
[0,1] | |
func sum(_ nums: [Int], _ target: Int) -> [Int] { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment