Created
August 14, 2021 11:27
-
-
Save r14152/b4ab3b10efe9871162489460727064c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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