Accepted 8 lines Golang solution


  • 0
    G
    func twoSum(nums []int, target int) []int {
        for i,v := range nums{
            for j:=i+1;j<len(nums);j++{
                if nums[j]==target-v{
                return []int{i,j}
                }
            }
        }
        panic("should never happen")
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.