Given an integer array nums, return an array where counts[i] is the number of smaller elements to the right of nums[i]. Example: nums returns . You solved this with segment trees. The BIT solution is cleaner:
Coordinate compress
Process right to left
For each element: query prefix count, then update Constraints: up to elements.