Skip to content

Instantly share code, notes, and snippets.

@juanfurattini
Created August 29, 2018 02:03
Show Gist options
  • Save juanfurattini/1f3b47c31cc619413d9a3f7f67de92f5 to your computer and use it in GitHub Desktop.
Save juanfurattini/1f3b47c31cc619413d9a3f7f67de92f5 to your computer and use it in GitHub Desktop.
def solution(a)
return 1 unless a.include?(1)
val = 0
a.uniq.sort.each do |e|
next if e <= 0
return val.next if e > val.next
val = e
end
val.next
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment