1
 2
 3
 4
 5
 6
 7
 8
 9
10
// @Title: 多数元素 (Majority Element)
// @Author: 15816537946@163.com
// @Date: 2020-06-25 07:15:36
// @Runtime: 24 ms
// @Memory: 5.9 MB
import "sort"
func majorityElement(nums []int) int {
    sort.Ints(nums)
    return nums[len(nums)/2]
}