Created
May 6, 2021 23:35
-
-
Save willshepp28/0fec25a4fb9cbd77cc0c2d1226c30bc9 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
# @param {Integer[]} candies | |
# @param {Integer} extra_candies | |
# @return {Boolean[]} | |
def kids_with_candies(candies, extra_candies) | |
greatest_value = 0 | |
#loop through the array and store the value with the greatest value | |
candies.each do |candy| | |
greatest_value = candy if candy > greatest_value | |
end | |
#loop back through and compare each value against the greatest value | |
return candies.map { |candy| | |
(candy += extra_candies) >= greatest_value ? true : false | |
} | |
#return the results | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment