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
def solution(a) | |
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 |
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
module ArrayUtils | |
extend self | |
# Converts a nested array to a flatten array without using the built-in method Array#flatten | |
# It doesn't remove nil | |
# | |
# If the passed parameter is not an array, the same object is returned | |
# to_flat_array(nil) #=> nil | |
# to_flat_array({ a: 'something }) #=> {:a=>"something"} | |
# If the passed parameter is a nested array, a flatten array is returned |
NewerOlder