Minimum swaps to sort an array

i haven’t studied graphs or vector yet…i am still on 1d array… can someone tell me how to solve this

You need to find the final order that elements will have after sorting. Now for every position ‘i’ you see if the element at this position is not the element that should be there in the final state after sorting, we start a cycle and keep jumping to elements until we reach same ‘i’. This cycle length -1 is added to the answer.
See this for reference https://www.geeksforgeeks.org/minimum-number-swaps-required-sort-array/

i said i haven’t studied graph or tree or vector is there any solution apart from this…i have only studied 1D array

No there isn’t. You need to study these topics.

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.