hello, I've done this by another way (with arraylist), but could you please tell me where is the problem in this way??
Result is fine, but I dont have all of Conditions fine.
package pl.codegym.task.task12.task1233;
/*
Nadchodzą izomorfy
*/
import java.util.*;
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("Minimum to " + result.x);
System.out.println("Indeks najmniejszego elementu to " + result.y);
}
public static Pair<Integer, Integer> getMinimumAndIndex(int[] array) {
if (array == null || array.length == 0) {
return new Pair<Integer, Integer>(null, null);
}
int index = 0;
for (int i = 0; i < array.length; i++) {
if (array[i] == index){
index = i;
}
}
Arrays.sort(array);
int min = 0;
for (int i = 0; i < array.length; i++) {
min = array[0];
}
//tutaj wpisz swój kod
return new Pair<Integer, Integer>(min, index);
}
public static class Pair<X, Y> {
public X x;
public Y y;
public Pair(X x, Y y) {
this.x = x;
this.y = y;
}
}
}