Majority Element 主元素
Description
Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it.
public class Solution {
/*
* @param nums: a list of integers
* @return: find a majority number
*/
public int majorityNumber(List<Integer> nums) {
// write your code here
Collections.sort(nums) ;
int len = nums.size()-1 ;
return nums.get(len / 2) ;
}
}