Forgive me, but I am very confused, and I can not find sources pointing to me in the right direction.
The specified list of n elements:
[3, 6, 5, 1]
Decrease values that do not exceed the size of the list, keeping the priority values relative to each other (in the original order).
Limitations:
- Order must be saved
- Elements> = 0
- Distinctive values
I try to stay away from sorting and creating a new list, but changing the list in place.
What should be my expected result:
[1, 3, 2, 0]
Is there an algorithm that exists for this problem?
source
share