Hey Guys, Everything look fine with this code, i tried manual entries (like ascendant, descendant sets with violators and some with not). I dont know why i don't pass the test in codegym. Someone here for a code review please ?
ArrayList<String> list = new ArrayList<>();

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        for (int i = 0; i < 10; i++) {
            list.add(reader.readLine());
        }

        ArrayList<Integer> violators = new ArrayList<>();

        int type = Integer.MAX_VALUE;
        if (list.get(1).compareTo(list.get(0)) > 0) {
            type = 1;
        } else {
            type = 2;
        }   // Type 1 = Ascendant  and Type2 = Descendant


        for (int i = 1; i < list.size(); i++) {
            String current = list.get(i);
            String previous = list.get(i - 1);
            if (type == 1 && current.compareTo(previous) < 0) {
                violators.add(i);
            }
            if (type == 2 && current.compareTo(previous) > 0) {
                violators.add(i);
            }
        }
        if (!violators.isEmpty()) {
            System.out.println(violators.get(0));
        }
Happy Coding !