思路:对两个list 排序,从小到大依次对比两个数组元素的差
class Solution(object): def smallestDifference(self, a, b): """ :type a: List[int] :type b: List[int] :rtype: int """ a.sort() b.sort() i = 0 j= 0 d = max(max(a),max(b)) while i<len(a) and j <len(b): d = min(abs(a[i]-b[j]),d) if a[i]>b[j]: j+=1 else: i+=1 return d