Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def differentValues(a, d)
- array_length = a.length
- x = 0
- y = 1
- difference = 0
- while (x < array_length)
- while (y < array_length)
- if (a[x] - a[y]).abs <= d and (a[x] - a[y]).abs > difference then
- difference = (a[x] - a[y]).abs
- end
- y = y + 1
- end
- x = x + 1
- y = x + 1
- end
- if difference == 0 then
- return -1
- else
- return difference
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment