Clear2 / Algorithm

算法训练
MIT License
0 stars 0 forks source link

数组中重复的数字 #11

Open Clear2 opened 4 years ago

Clear2 commented 4 years ago
func findRepeatNumber(nums []int) int {
    maps := make(map[int]bool)
    for _,num:=range nums{
        if maps[num]{
            return num
        }else{
            maps[num]=true
        }
    }
    return -1
}

hash表的解法,不算太好