Skip to content

Instantly share code, notes, and snippets.

@idimitrov07
Created February 11, 2017 14:31
Show Gist options
  • Select an option

  • Save idimitrov07/d138eab8044ce5202dd3cdb53a62774d to your computer and use it in GitHub Desktop.

Select an option

Save idimitrov07/d138eab8044ce5202dd3cdb53a62774d to your computer and use it in GitHub Desktop.
n = gets.strip.to_i
a = gets.strip
arr = a.split(' ').map(&:to_i)
# your code goes here
min = 2147483647
arr.sort!
(1...arr.size).each do |i|
diff = (arr[i - 1] - arr[i]).abs
if diff < min
min = diff
end
end
puts min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment