Last active
June 22, 2017 01:00
-
-
Save dustMason/0c5997b8fafd3e2b8db8ef7b2455a128 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
class Solution | |
# @param a : array of integers | |
# @return an integer | |
def solve(a) | |
found = -1 | |
sorted = a.select { |n| n >= 0 }.sort | |
s = sorted.size | |
sorted.each_with_index do |n, i| | |
if n >= 0 && n == s - 1 - i && sorted[i+1] != n | |
found = 1 | |
break | |
end | |
end | |
return found | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment