Golang Solution - I think this is what they want. funky data structure workaround


  • 0
    N

    Here you go, simple implementation using map

    func singleNumber(nums []int) int {
    mm := make(map[int]int)

    for _,v := range nums{
        mm[v]++
    }
    for k,v := range mm{
        if v == 1{
            return k
        }
    }
    return -1
    

    }


Log in to reply
 

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