逐渐逼近
class Solution {
public int smallestDifference(int[] a, int[] b) {
int len1 = a.length, len2 = b.length;
Arrays.sort(a);Arrays.sort(b);
long result = Integer.MAX_VALUE;
int i = 0, j = 0;
while(i < len1 && j < len2){
result = Math.min(result, Math.abs((long)a[i] - (long)b[j]));
if(a[i] < b[j]) ++i;
else ++j;
}
return (int)result;
}
}