Number of Swaps to Sort

https://algo.monster/problems/amazon_oa_number_of_swaps_to_sort

I am not very sure why the below is not the solution:

public static int numberOfSwapsToSort(List nums) {
int count = 0;

    for (int i = 0; i < nums.size(); i++) {
        
        int minItemLoc = i;
        
        for (int j = i + 1; j < nums.size(); j++) {
            if (nums.get(j) < nums.get(minItemLoc)) {
                minItemLoc = j;
            }
        }
        
        if (i != minItemLoc) {
            swap(nums, i, minItemLoc);
            count++;
        }
    }
    return count;
}

private static void swap(List<Integer> nums, int i, int j) {
    int temp = nums.get(i);
    nums.set(i, nums.get(j));
    nums.set(j, temp);
}
maxnumindex=nums.index(max(nums))
print(maxnumindex)
swapmax=len(nums)-(maxnumindex+1)
minimumindex=nums.index(min(nums))
print(minimumindex)
swapmin=(minimumindex+1)-1
return swapmax + swapmin