114. Count of Smaller Numbers After Self
Hard · Array
Given an integer array, for each position compute how many numbers to its right are strictly smaller than it.
The input is the array. Return an array of the same length where the value at each index is that count.
Examples
Example 1 Input: [5,2,6,1] Output: [2,1,1,0] Explanation: After 5 there are 2 smaller (2,1); after 2 there is 1 (1); after 6 there is 1 (1).
Example 2 Input: [-1] Output: [0] Explanation: A single element has nothing to its right.
Constraints
- Standard input/output constraints apply