Skip to content

Instantly share code, notes, and snippets.

@dustMason
Last active June 22, 2017 01:00
Show Gist options
  • Save dustMason/0c5997b8fafd3e2b8db8ef7b2455a128 to your computer and use it in GitHub Desktop.
Save dustMason/0c5997b8fafd3e2b8db8ef7b2455a128 to your computer and use it in GitHub Desktop.
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