Mark and Toys Discussions | Algorithms | HackerRank

Mark and Toys

  • + 0 comments
    def maximumToys(prices, k):
        # Write your code here
        prices.sort()
        current=0
        toys=0
        for toy in prices:
            if toy+current<=k:
                current+=toy 
                toys+=1
        return toys