How to assign ranks to elements in a given list of integers? Is there an algorithm for that with time complexity less than O(n^2) ?
Input: 2 6 7 3 9
Output: 1 3 4 2 5
How to assign ranks to elements in a given list of integers? Is there an algorithm for that with time complexity less than O(n^2) ?
Input: 2 6 7 3 9
Output: 1 3 4 2 5
Copyright © 2021 Jogjafile Inc.
You can easily do this in
O(n * log n)
by sorting: