leetcode题解1:Two Sum

/ 默认分类 / 没有评论 / 96浏览

Two Sum


func twoSum(nums []int, target int) []int {
    for i := 0; i < len(nums); i++ {
        for j := 0; j < len(nums); j++ {
            if i != j {
                if nums[i]+nums[j] == target {
                    return []int{i,j}
                }
            }
        }
    }
    return []int{}
}