260. Count of Smaller Numbers After Self

Hard · Divide and Conquer

Given an integer array `nums`, return an array `counts` where `counts[i]` is the number of smaller elements to the right of `nums[i]`.

Examples

Example 1
Input: nums = [5, 2, 6, 1]
Output: [2, 1, 1, 0]
Explanation: 5 has [2,1] smaller to right; 2 has [1]; 6 has [1]; 1 has []

Constraints