public static void main(String args[]){
        int input[] =  {12, 1, 2, 3, 0, 11, 4};
        CountNumberOfSmallerElementOnRight cns = new CountNumberOfSmallerElementOnRight();
        int count[] = cns.count(input);
        for(int c : count){
            System.out.print(c + " ");
        }
        System.out.println();
        int input1[] = {5, 4, 3, 2, 1};
        int count1[] = cns.count(input1);
        for(int c : count1){
            System.out.print(c + " ");
        }
        
        System.out.println();
        int input2[] = {1,2,3,4,5};
        int count2[] = cns.count(input2);
        for(int c : count2){
            System.out.print(c + " ");
        }
    }
http://www.geeksforgeeks.org/count-smaller-elements-on-right-side/
Test cases
All same elements
Many duplicates
Negative numbers
0s
Sorted or reverse sorted
src/com/interview/tree/CountNumberOfSmallerElementOnRight.java