@@ -0,0 +1,641 @@
+%0Apublic class Leader%0A%7B%0A    /**%0A     * leader of array is element who repeated more than n/2 time where n is%0A     * length of array. it return -1 iff no leader found%0A     * %0A     * @param arr%0A     * @return%0A     */%0A    public static int getLeader(int%5B%5D arr)%0A    %7B%0A%09int count = 0;%0A%09int pos = (arr.length + 1) / 2;%0A%09int candidate = arr%5Bpos%5D;%0A%09for (int i = 0; i %3C arr.length; i++)%0A%09%7B%0A%09    if (candidate == arr%5Bi%5D)%0A%09%09count++;%0A%09%7D%0A%0A%09if (count %3E pos)%0A%09    return candidate;%0A%0A%09return -1;%0A%0A    %7D%0A%0A    public static void main(String%5B%5D args)%0A    %7B%0A%09int%5B%5D test = %7B 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 4 %7D;%0A%09System.out.println(getLeader(test));%0A%0A    %7D%0A%0A%7D%0A

Create Leader.java