Question bank › Greedy
Dsa Greedy Medium

Maximize Profit from Projects

You are given a number of projects, each of which requires some time to complete and yields a certain profit. You can only work on one project at a time, and your goal is to maximize the total profit. You have a limited amount of time to work on projects. Input format: - The first line contains two integers, T (total time available) and P (number of projects). - The next P lines contain two integers each: the time required for the project and the profit earned from it. Output format: - Print a single integer: the maximum profit you can earn under the time constraint. Example: Input: 10 4 2 40 3 50 4 70 5 60 Output: 120

Key concepts

greedyprofit maximizationsorting

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.