https://algo.monster/problems/count_of_smaller_numbers_after_self

Please make animation little slower. Its too fast to understand.

You can view the images manually.

“To answer that question we just have to sum up the numbers in the above output array: 2 + 1 + 1 = 5 swaps.”

Should be 2 + 1 + 1 = 4…

Thanks, we’ve fix it.

not for this one, it appears as a gif for me

I found it more intuitive to write a bubble sort that tracked the number of times a an element was pushed down the list in a dictionary. How does that compare to this solution?

Bubble sort is a O(n^2) solution. It would be equivalent (and easier) to just to a double for loop counting the number of smaller elements after the current one, with the inner loop starting from the end of the array and going to the index of the outer loop. However, that would not be the optimal solution.

This is exactly what I needed, thanks!