Given array , for each element, count how many elements to its right are smaller. Example: returns .
- Right of 5: 2 and 1 are smaller (count 2)
- Right of 2: 1 is smaller (count 1)
- Right of 6: 1 is smaller (count 1)
- Right of 1: nothing (count 0)
This you can solve with wavelet trees by querying "count less than in range ." Constraints: up to elements.