public List<Integer> countSmaller(int[] nums) {
        if (nums.length == 0) {
            return new ArrayList<>();
        }
        NumberIndex[] input = new NumberIndex[nums.length];
        for (int i = 0; i < nums.length; i++) {
            input[i] = new NumberIndex(nums[i], i);
        }

        int result[] = new int[nums.length];

        mergeUtil(input, result, 0, input.length - 1);

        List<Integer> r = new ArrayList<>();
        for (int s : result) {
            r.add(s);
        }
        return r;
    }
Date 03/01/2016
@author Tushar Roy

Count number of smaller elements on right side of an array for every element.

Time complexity is O(nlogn)
Space complexity is O(n)

https://leetcode.com/problems/count-of-smaller-numbers-after-self/
src/com/interview/array/CountSmallerOnRight.java