LeetCode 第 1 题: 两数之和

1
2
3
4
5
6
7
8
9
10
func twoSum(nums []int, target int) []int {
for i:=0;i< len(nums) - 1;i++{
for k := i + 1; k< len(nums); k++{
if(nums[i] + nums[k] == target){
return []int{i,k}
}
}
}
return []int{}
}