plduhoux
2/21/2018 - 8:40 PM

differentValues

int differentValues(int[] a, int d) {
    int max = -1; 
    for (int i = 0; i < a.length - 1; i++) {
        for (int j = i + 1; j< a.length; j++) {
            if (Math.abs(a[i] - a[j]) <= d && max < Math.abs(a[i] - a[j])) max = Math.abs(a[i] - a[j]);
        }
    }
    return max;
}