Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Map the original numbers to new numbers by the mapping rule and sort the new numbers.
To maintain the same relative order for equal mapped values, use the index in the original input array as a tiebreaker.