How could I find the inverse of an array?

can you please explain how should I determine the inverse of an array ???

Logic: Inverse is Simply swapping the value of the array with the value at that index.

Algo

  1. Create a new Array say narr and original array is arr.
  2. now at the arr[i]th index of narr save the ith value.(previously i is the index and arr[i] is the value bt now arr[i] is the index and i is the value.)
  3. print new array.

code --> https://ide.codingblocks.com/s/657727

Hi, Thank you for the answer. We can simply swap the index and the value of the array to find the inverse.

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.