You are viewing a single comment's thread. Return to all comments →
func lonelyinteger(a []int32) int32 { // Write your code here // var r int32 = 0 // for _, a := range a{ // r ^= a // } // return r var result int32 = 0 m := make(map[int32]int32) for _, v :=range a{ value, exists := m[v] if exists{ m[v] = value+1 // fmt.Printf("Exist: key= %d, not= %d", v, value+1) }else{ m[v] = 1 // fmt.Printf("Newone: key= %d, not= %d", v, 1) } } for key, value := range m{ if value == 1{ result = key } } return result }
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →