@@ -0,0 +1,843 @@
+/***%0A * Given an array of size n, find the majority element. The majority element is the element that appears more than %5B n/2 %5D times.%0A *%0A * You may assume that the array is non-empty and the majority element always exist in the array.%0A *%0A * Credits:%0A * Special thanks to @ts for adding this problem and creating all test cases.%0A */%0A/*%0A * Moore's Voting Algorithm%0A * */%0Apublic class Solution %7B%0A    public int majorityElement(int%5B%5D num) %7B%0A        int maj = 0;%0A        int n = num.length;%0A        int count = 0;%0A        for (int i = 0; i %3C n; i++) %7B%0A            if (count == 0) %7B%0A                maj = num%5Bi%5D;%0A                count++;%0A            %7Delse if (num%5Bi%5D == maj) %7B%0A                count++;%0A                if (count %3E n/2)%0A                    return maj;%0A            %7Delse%0A                count--;%0A        %7D%0A        return maj;%0A    %7D%0A%7D%0A

add MajorityElement.java