Skip to content

Instantly share code, notes, and snippets.

@r14152
Created August 14, 2021 11:27
Show Gist options
  • Save r14152/b4ab3b10efe9871162489460727064c6 to your computer and use it in GitHub Desktop.
Save r14152/b4ab3b10efe9871162489460727064c6 to your computer and use it in GitHub Desktop.
func twoSum(nums []int, target int) []int {
data :=make(map[int]int,0)
returnData := make([]int,0)
for i:=0;i< len(nums);i++{
if val,found := data[target-nums[i]];found{
returnData = append(returnData, val, i)
break
}else{
data[nums[i]] =i
}
}
return returnData
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment