hackerrank/interview_preparation_kit_sorting_bubble_sort.rb
# Complete the maximumToys function below.
Complete the maximumToys function below.
Complete the maximumToys function below .
def maximumToys(prices, k)
  result = []
  buyable_prices = prices.select { |price| k >= price }.sort
  1.upto(buyable_prices.size) do |i|
    result += buyable_prices
                .each_cons(i)
                .to_a
                .select { |c| k >= c.sum }
  end
  result.last.size
end
def maximumToys ( prices , k ) result = [ ] buyable_prices = prices . select { | price | k >= price } . sort 1 . upto ( buyable_prices . size ) do | i | result += buyable_prices . each_cons ( i ) . to_a . select { | c | k >= c . sum } end result . last . size end
Complete the maximumToys function below.
Complete the maximumToys function below .
prices
<not_specific>
k
<not_specific>