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.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console