public int majorityElement(int[] nums) {
Arrays.sort(nums);
int len = nums.length;
return nums[len/2];
}
my very simple java solution


@daggarwa “You may assume that the array is nonempty and the majority element always exist in the array.” This is the assumption of this problem. :0