Created
February 11, 2017 14:31
-
-
Save idimitrov07/d138eab8044ce5202dd3cdb53a62774d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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