Вроде бы все правильно, но по последнему пункту валидацию не проходит. Пробовал по разному сортировать и выводить, в idea все правильно - и число и индекс, при этом валидатор ругается.
package com.javarush.task.task12.task1233;
/*
Изоморфы наступают
*/
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws Exception {
int[] data = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5};
Pair<Integer, Integer> result = getMinimumAndIndex(data);
System.out.println("The minimum is " + result.x);
System.out.println("The index of the minimum element is " + result.y);
}
public static Pair<Integer, Integer> getMinimumAndIndex(int[] array) {
if (array == null || array.length == 0) {
return new Pair<Integer, Integer>(null, null);
}
for(int i = 0; i < array.length; i++){
for(int l = i + 1; l < array.length; l++){
if(array[i] > array[l]){
int tmp = array[i];
array[i] = array[l];
array[l] = tmp;//напишите тут ваш код
}
}
}
ArrayList<Integer> list = new ArrayList<>();
for(int j = 0; j < array.length; j++) list.add(array[j]);
int min = list.get(0);
return new Pair<Integer, Integer>(min, list.indexOf(min));
}
public static class Pair<X, Y> {
public X x;
public Y y;
public Pair(X x, Y y) {
this.x = x;
this.y = y;
}
}
}