Created
November 2, 2023 15:41
-
-
Save claudiokerekes/c528a2ee66263b8159b0023d08199d2f to your computer and use it in GitHub Desktop.
This file contains 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
def get_positive(array) | |
arr = array.uniq.sort | |
smallest = 1 | |
arr.each do |num| | |
if num == smallest | |
smallest += 1 | |
elsif num > smallest | |
return smallest | |
end | |
end | |
puts "nothing" | |
end | |
irb(main):141> get_positive(data2) <= [1,2,3,4,5] | |
nothing | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment