Inverse of number(daily code)

Take the following as input.
A number
Assume that for a number of n digits, the value of each digit is from 1 to n and is unique. E.g. 32145 is a valid input number.

Write a function that returns its inverse, where inverse is defined as follows

Inverse of 32145 is 12543. In 32145, “5” is at 1st place, therefore in 12543, “1” is at 5th place; in 32145, “4” is at 2nd place, therefore in 12543, “2” is at 4th place.


i am not able to get any idea ,how to approach this question
also i see the solution and algorithm of this in hacker block solution , but still not able to understand

Hey @aattuull we are given initial string like 12345, so we can give places to every digit, like in this case we will say that 5 is on 1st place, 4 is on 2nd place and so on. Now we just have to invert this relationship so if 5 was on 1st place, after inverting this relationship 1 would be on 5th place.

Before Inverse

Places --> 5 4 3 2 1
Value ---> 3 2 1 4 5

After Inverse

Places --> 5 4 3 2 1
Value ---> 1 2 5 4 3

We can see in this example before inverse 4 was on 2nd place and after inverse 2 moved to 4th place.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.