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 understand the question and also the logic which is present on hackerblock
public static int inverse(int num){
int place = 1;
int mult = 1;
int ans = 0;
while(num != 0){
int rem = num % 10;
ans = ans + place * (int)Math.pow(10, rem - 1);
num = num / 10;
place++;
}
return ans;
}