Skip to content
16 changes: 16 additions & 0 deletions two-sum/SeongA.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
var dictionary: [Int: Int] = [:]
for (index, value) in nums.enumerated() {
let difference = target - value
if let otherIndex = dictionary[difference] {
return [otherIndex, index]
}
dictionary[value] = index
}
return []
}
}



Loading