赞
踩
题目:
题解:
- func majorityElement(nums []int) (ans []int) {
- cnt := map[int]int{}
- for _, v := range nums {
- cnt[v]++
- }
- for v, c := range cnt {
- if c > len(nums)/3 {
- ans = append(ans, v)
- }
- }
- return
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。