Created
August 2, 2017 15:56
-
-
Save luojiyin1987/f5781fa84353726b50b663293c17dd97 to your computer and use it in GitHub Desktop.
Single Number
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
| //write by myself | |
| func singleNumber(nums []int) int { | |
| temp :=map[int]int{} | |
| var single int | |
| for _ , n := range nums { | |
| if _, ok := temp[n] ; ok { | |
| temp[n] = temp[n]+1 | |
| } else { | |
| temp[n] =0 | |
| } | |
| } | |
| for k,v := range temp{ | |
| if v== 0 { | |
| single = k | |
| } | |
| } | |
| return single | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment