Force link :https://leetcode-cn.com/probl...
Their thinking :
- Solution 1 : Hashtable , Traversing arrays directly , Record the number of each number , Then find a number larger than normal
- Solution 2 : Because most of the elements in the array , Then you can sort this array , The element in the middle must be at most more than half of the elements
func majorityElement(nums []int) int {
sort.Ints(nums)
return nums[len(nums) / 2]
}


![[shutter] statefulwidget component (pageview component)](/img/0f/af6edf09fc4f9d757c53c773ce06c8.jpg)

![[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology](/img/2f/bb99836bb3ad725483f30531ff4d53.jpg)



![The web version of xshell supports FTP connection and SFTP connection [detailed tutorial] continued from the previous article](/img/8f/6759b4685a129f9d10d6ea1dc8e61e.jpg)