Jump between number in array

I want two compare two arrays. One of them is a subset of the other one. I want my function to return the minimum equal gap between the numbers of the first subset array.
For example if I have

arr1 = 2,1,4,2,8,3
arr2 = 1,2,3
I want my function to return 1 because the mimimum gap between all this numbers are 1.

arr1 = 2,1,5,2,1,2,3
arr2 = 1,2,3
I want my function to return 0 because the mimimum and equal gap between 1,2,3 in arr1 is 0

I don't know how to do this nested loop.Can you help me achieve this..
Last edited on
Topic archived. No new replies allowed.