You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order.
YES
As it has not beed added in any issue in hakin-codes.
Very Common Algorithm. It is Useful in Solving Many Graph related Problems.
@Kajol-Kumari @SKAUL05 @Abhijit2505 @plazzy99 @siddharth25pandey
Can you please add the relevant labels to it and assign the issue to me. Thank you!
Hey @DrSehgal7 can you please mention the language you are going to do it?
@Kajol-Kumari Would like to work on C++ and C both
I would like to work on this in Python
I would like to work on this in Java.
@ritvij14 go with java
@DrSehgal7 I had a doubt about this algorithm. Is the array consisting of any set of consecutive integers that are arranged unordered? Or is it like the first N consecutive integers from 1 to N?
@ritvij14 For example N= 50 so you will have an array of 50 elements and all of them will be from 1 to 50 without duplicates.
For eg:-
N=10
array[]={3 7 6 9 1 8 10 4 2 5}
ans=9
I hope your doubt is clear now!
@DrSehgal7 yes it's clear now, thanks for the clarification. :D
Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Telegram or ping one of the reviewers. Thank you for your contributions!
Most helpful comment
@Kajol-Kumari @SKAUL05 @Abhijit2505 @plazzy99 @siddharth25pandey
Can you please add the relevant labels to it and assign the issue to me. Thank you!