Topcoder SRM 475 "RabbitVoting"

問題:http://www.topcoder.com/stat?c=problem_statement&pm=10881 (要ログイン)

Go言語で書く練習.
mapを使ってみる.

func GetWinner(names, votes []string) (winner string) {
        voted := make(map[string]int,len(names))
        max := 0
        l:for pos,key := range votes {
                if names[pos]!=key {
                        voted[key]++
                        if max < voted[key] {
                                max = voted[key]
                        }
                }
        }
        for key,value := range voted{
                if value == max {
                        if winner == ""{
                                winner = key
                        }else{
                                return ""
                        }
                }
        }
        return
}