Created
December 16, 2019 11:15
-
-
Save spurscho/50f215d465c8cccd289d053f14cc5cbc to your computer and use it in GitHub Desktop.
Leetcode 1. TwoSum
This file contains hidden or 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
class Solution { | |
func twoSum(_ nums: [Int], _ target: Int) -> [Int] { | |
var arrRes: [Int] = [] | |
var res: Int = 0 | |
for i in 0..<nums.count-1 { | |
for j in i+1..<nums.count { | |
if (nums[i] + nums[j]) == target { | |
arrRes.append(i) | |
arrRes.append(j) | |
return arrRes | |
} | |
} | |
} | |
return arrRes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment