We’re preparing your current view and syncing the latest data.
You are given an integer array nums. For each nums[i], you need to find the number of elements in the array that are smaller than nums[i]. Return the answer in an array.
An integer array nums.
An integer array where each element represents the count of numbers smaller than the corresponding element in nums.
1 <= nums.length <= 500 0 <= nums[i] <= 100
Example 1
Input
nums = [8,1,2,2,3]
Output
[4,0,1,1,3]
Explanation
For nums[0] = 8, smaller numbers are 1,2,2,3 (4 numbers). For nums[1] = 1, no smaller numbers. For nums[2] = 2, smaller number is 1 (1 number). For nums[3] = 2, similarly 1 smaller number. For nums[4] = 3, smaller numbers are 1,2,2 (3 numbers).