Question bank › Greedy
Dsa Greedy Warm-up

Fruit Basket

You are at a market buying fruits and each fruit has a price. Given a budget, find out how many types of fruit you can buy if you want to maximize variety. Input consists of an integer n (the number of different fruits) followed by n integers (the price of each fruit) and a final integer representing the budget. Output the number of different types of fruit you can buy. Example: Input: 5 10 15 20 30 50 100 Output: 4

Key concepts

greedyarrayselection

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.