Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 1.23 KB

File metadata and controls

23 lines (19 loc) · 1.23 KB

Inverse of A Number

Easy


  1. You are given a number following certain constraints.
  2. The key constraint is if the number is 5 digits long, it'll contain all the digits from 1 to 5 without missing any and without repeating any.
  3. E.g. 23415 is a 5 digit long number containing all digits from 1 to 5 without missing and repeating any digit from 1 to 5.Take a look at few other valid numbers - 624135, 81456273 etc.Here are a few invalid numbers - 139, 7421357 etc.
  4. The inverse of a number is defined as the number created by interchanging the face value and index of digits of number.
  5. E.g. for 426135 (reading from right to left, 5 is in place 1, 3 is in place 2, 1 is in place 3, 6 is in place 4, 2 is in place 5 and 4 is in place 6), the inverse will be 416253 (reading from right to left, 3 is in place 1, 5 is in place 2,2 is in place 3, 6 is in place 4, 1 is in place 5 and 4 is in place 6) More examples - inverse of 2134 is 1243 and inverse of 24153 is 24153
  6. Take as input number "n", assume that the number will follow constraints.
  7. Print it's inverse.

Example 1:

Input:  28346751
Output:  73425681

Constraints:

1 <= n < 10^8, and follwing other constraints defined above.