values and, for each day, wants to know how many later days had a smaller change.
Return an array of the same length whose entry i is the number of indices j > i with values[j] < values[i] (strictly smaller).
Checking every pair takes O(n²); aim for something faster.values=[3, 7, 1, 7, 2] → [2, 2, 0, 1, 0]
To the right of 3 the smaller values are 1 and 2; the first 7 also has 1 and 2 (the other 7 is not smaller); nothing smaller follows 1; the second 7 is followed only by 2; the last element has nothing to its right.
values=[4, 4, 4] → [0, 0, 0]
Equal values do not count as smaller, so every count is zero.
values=[-5] → [0]
values=[3, 7, 1, 7, 2]
[2, 2, 0, 1, 0]
Run checks the first 3 tests in your browser. Submit checks all 138 tests on the server, hidden ones included.