@@ -0,0 +1,623 @@
+/**%0A *%09Given an array of size n, find the majority element. %0A *%09The majority element is the element that appears more than %E2%8C%8A n/2 %E2%8C%8B times.%0A *%0A *%09You may assume that the array is non-empty and the majority element always exist in the array.%0A *%09%0A *%09Challenge: O(n) time and O(1) extra space%0A *%0A *%09Author: matao%0A *%0A */%0A%0Aimport java.util.Arrays;%0A%0Apublic class MajorityElement %7B%0A%09public static int majorityElement(int%5B%5D nums) %7B%0A%09%09Arrays.sort(nums);%0A%09%09return nums%5Bnums.length / 2%5D;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09int%5B%5D nums = %7B1, 1, 1, 1, 2, 2, 2%7D;%0A    %09System.out.println(majorityElement(nums));%0A    %7D%0A%7D

add Majority Element solution