@@ -0,0 +1,1497 @@
+package tasks;%0A%0A/**%0A * Created by khalil on 22/05/15.%0A */%0Apublic class Task1 %7B%0A    public static void main(String%5B%5D args) %7B%0A%0A        int%5B%5D A = new int%5B7%5D;%0A        /* A%5B0%5D = 2;%0A        A%5B1%5D = 2;%0A        A%5B2%5D = 5;%0A        A%5B3%5D = 5;%0A        A%5B4%5D = 5;%0A        A%5B5%5D = 4;*/%0A        A%5B0%5D = 5;%0A        A%5B1%5D = 5;%0A        A%5B2%5D = 1;%0A        A%5B3%5D = 7;%0A        A%5B4%5D = 2;%0A        A%5B5%5D = 3;%0A        A%5B6%5D = 5;%0A        System.out.println(solution(5, A));%0A    %7D%0A%0A    public static int solution(int X, int%5B%5D A) %7B%0A        // write your code in Java SE 8%0A%0A        int cptk = 0, cptKMin = 0;%0A        // The range %5B1..100,000%5D%0A        if (A.length %3E 100000 %7C%7C A.length %3C 1) %7B%0A            // The minimal positive integer%0A            return -1;%0A        %7D%0A%0A        // The range %5B1..100,000%5D%0A        if (X %3E 100000 %7C%7C A.length %3C 0) %7B%0A            // The minimal positive integer%0A            return -1;%0A        %7D%0A%0A%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            // Element range %5B0..100,000%5D%0A            if (A%5B0%5D %3E 100000 %7C%7C A%5B0%5D %3C 0 %7C%7C A%5B0%5D %3E 100000 %7C%7C A%5B0%5D %3C 0) return -1;%0A%0A            cptKMin = 0;%0A            if (X == A%5Bi%5D ) %7B%0A                cptk++;%0A            %7D%0A            for (int j = i; j %3C A.length; j++) %7B%0A                if (X != A%5Bj%5D) %7B%0A                    cptKMin++;%0A%0A                %7D%0A%0A            %7D%0A            System.out.println(cptk + %22 , %22 + cptKMin);%0A%0A            if (cptk == cptKMin && X == A%5B0%5D) return i;%0A            if (cptk == cptKMin) return i + 1;%0A%0A%0A        %7D%0A%0A        return -1;%0A    %7D%0A%7D%0A

Task1