0

I have a vector, something like this :

[11,12,0,0,12,4,3,3,4]

and I want to rank it so its something like this :

[3,4,0,0,4,2,1,1,2]

If someone could provide some outlook on how this might be possible, it would be quite helpful. Thanks

Erklik
  • 3
  • 3

1 Answers1

0

Use arrays instead of vectors. int xarray[] = {}. The steps to make this possible would include:

Create a temp array without the duplicates

Sort the temp array

Point the temp array to a new array of equal size where each value represents the index of the temp array

Loop through the original array and update each value to equal the result from the pointer array using an index based off said value.

Jesse
  • 283
  • 1
  • 5
  • 14