HackerRank Minimum Swaps 2 Problem [Solved]

https://www.hackerrank.com/challenges/minimum-swaps-2/problem No worries! It is as simple as HELL!!

    static int minimumSwaps(int[] arr) {
            int swapCount = 0;
            for (int index = 0; index < arr.Length - 1; index++)
            {
                if (arr[index] != (index + 1))
                {
                    for (int swapIndex = index + 1; swapIndex < arr.Length; swapIndex++)
                    {
                        if (arr[swapIndex] == (index + 1))
                        {
                            int aux = arr[swapIndex];
                            arr[swapIndex] = arr[index];
                            arr[index] = aux;
                            swapCount++;
                            break;
                        }
                    }
                }
            }
            return swapCount;   
}

Read more...