public int findInversions(int input[]) {
        int inversion = 0;
        for (int i = 1; i < input.length - 1 ; i++) {
            int larger = 0;
            for (int k = 0; k < i; k++) {
                if (input[k] > input[i]) {
                    larger++;
                }
            }
            int smaller = 0;
            for (int k = i+1; k < input.length; k++) {
                if (input[k] < input[i]) {
                    smaller++;
                }
            }
            inversion += smaller*larger;
        }
        return inversion;
    }
Time complexity of this method is O(n^2)
Space complexity is O(1)
src/com/interview/array/CountInversionOfSize3.java