@@ -0,0 +1,1110 @@
+package array;%0A%0Aimport java.util.Scanner;%0A%0A/**%0A * n is odd%0A * 1%3C= n %3C= 1000001%0A * -10000 %3C= x %3C= 10000%0A *%0A * @see %3Ca href=%22https://www.hackerrank.com/challenges/find-the-median/submissions/code/27801277%22%3Ehacker rank%3C/a%3E%0A */%0Apublic class HackerrankFindtheMedian %7B%0A    public static void main(String%5B%5D args) %7B%0A        Scanner s = new Scanner(System.in);%0A        int%5B%5D ar = new int%5Bs.nextInt()%5D;%0A        int min = Integer.MAX_VALUE;%0A        int max = Integer.MIN_VALUE;%0A        for (int i = 0; i %3C ar.length; i++) %7B%0A            ar%5Bi%5D = s.nextInt();%0A            min = Math.min(min, ar%5Bi%5D);%0A            max = Math.max(max, ar%5Bi%5D);%0A%0A        %7D%0A        int%5B%5D num = new int%5Bmax - min + 1%5D; // ar may be have duplicated member%0A        for (int i = 0; i %3C ar.length; i++) %7B%0A            num%5Bar%5Bi%5D - min%5D++;%0A        %7D%0A        int count = 0;%0A        for (int i = 0; i %3C num.length; i++) %7B%0A            if (num%5Bi%5D != 0 && num%5Bi%5D + count %3E= ar.length / 2 + 1) %7B// care: %3E=%0A                System.out.println(i + min);%0A                break;%0A            %7D else %7B%0A                count += num%5Bi%5D;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Hackerrank Find the Median