Count of Smaller Numbers After Self

Hard
Arrays Merge Sort BIT
For each element, count elements to its right that are smaller. Input: space-separated nums Output: space-separated counts

Constraints

See problem-specific constraints. Optimized solution required.

Examples

Example 1:
Input: 5 2 6 1
Output:
Example 2:
Input: 5 2 6 1
Output:

Hints

Consider a merge sort approach.
Think about time complexity.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.