• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
May 07, 2024 |100 Views
SDE Sheet - Maximize Toys
  Share   Like
Description
Discussion

This video is part of the Greedy section under GFG SDE Sheet.

In this problem, we are given an array arr[ ] of length N consisting cost of N toys and an integer K depicting the amount with you. Your task is to find maximum number of toys you can buy with K amount.

Example :

Input: 
N = 7 
K = 50
arr[] = {1, 12, 5, 111, 200, 1000, 10}
Output: 4
Explanation: The costs of the toys you can buy are 1, 12, 5 and 10.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/maximise-the-number-of-toys-that-can-be-purchased-with-amount-k/
Problem: https://www.geeksforgeeks.org/problems/maximize-toys0331/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/