class ArrayMinimumDistance {
// 数组长度都不为空
public int minDistance(int[] a, int b[]) {
int min = a[0] - b[0];
for (int i = 0, j = 0; i < a.length && j < b.length; ) {
int value = a[i] - b[j];
if (value == 0) {
return 0;
} else {
min = getMin(value, min);
(value > 0) ? (j += 1) : (i += 1)
}
}
return min;
}
public int getMin(int a, int b) {
return a > b ? b : a;
}
}