func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
if nums.count < 2{
return [];
}
for i in 0..<nums.count - 1{
let num1 = target - nums[i]
for j in (i + 1)..<nums.count{
if nums[j] == num1{
return [i, j];
}
}
}
return [];
}
网友评论