---
# System prepended metadata

title: Leetcode 169. Majority Element
tags: [Array]

---

# Leetcode 169. Majority Element
Runtime: 1 ms
faster than 99.93% 

Memory Usage: 44.8 MB
less than 66.13%

``` java=
class Solution {
    public int majorityElement(int[] nums) {
        Arrays.sort(nums);
        
        return nums[nums.length/2];
    }
}
```
解題思維:
因題目說，最多的數至少要超過n/2，故排序好後直接找n/2的地方，一定是最多的數。


Arrars.sort()
>https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/433909/

###### tags: `Array`