Created
October 20, 2016 08:01
-
-
Save kobigurk/89b2ade0d6c7b20e460b8fa594862d5d 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
sorted = candy.sort.to_a | |
sorted.each_with_index{|item, index| index+k-1 >= sorted.size() ? (results[index] = Float::INFINITY) : (results[index] = (sorted[index+k-1] - sorted[index]))} | |
ans = results.min |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment