### Find smallest different in given two arrays

##### Algorithm:

- Sort both arrays
- Set minDiff = INFINITY
- Set a1Counter = 0 and a2Counter = 0
- Iterate till has array has not reached end
- If abs(A1[a1Counter] – A2[a2Counter]) < minDiff then
- Set minDiff = abs(A1[a1Counter] – A2[a2Counter]

- if A1[a1Counter] < A2[a2Counter] then
- Set a1Counter = a1Counter + 1

- else
- Set a2Counter = a2Counter + 1

- If abs(A1[a1Counter] – A2[a2Counter]) < minDiff then
- return minDiff

Latest Source Code:

Github: SmallestDifferenceInTwoArrays.java

**Output:**

Minimum difference: 3 Minimum difference: 1