Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].
Return the answer in an array.
Creating an array that documents the number of times each element appears inside the original array. Then, count up the number of times each element less than the current element appears.
Find the max number (max) in the int array (nums)
Create a hash table of size max+1 (hash)
Add every element to its corresponding index
Eg. nums[0] = 2, then hash[2] = 1
Then, for every number in nums, add up every index in hash until the index in hash is equal to the value of the current number
For example: nums = [1, 2, 3, 4]
max = 4
hash = [* * * * *] (empty array of size 5)
hash = [0, 1, 1, 1, 1] (every element appears only once, except for 0)
ans[0] = hash[0] = 0
ans[1] = hash[0] + hash[1] = 1
ans[2] = hash[0] + hash[1] + hash[2] = 2
ans[3] = hash[0] + hash[1] + hash[2] + hash[3] = 3
ans = [0, 1, 2, 3]