Question bank › Dynamic Programming
Dsa Dynamic Programming Easy

Escalating Cargo Load

You are loading a plane with a weight capacity C. You are given N items, each with a weight W[i] and a value V[i]. There is a strict 'Escalating Rule': if you pick multiple items, each item you add must have a strictly greater weight than the item added immediately before it. Maximize the total value of items loaded within capacity C. Input Format: Line 1: N C Next N lines: weight W[i] and value V[i] Output Format: A single integer max value. Example: Input: 3 10 2 10 5 20 3 15 Output: 30 Explanation: Pick (2, 10) then (3, 15). Total weight 5, Value 25. Or pick (2, 10) then (5, 20), Total weight 7, Value 30. (3, 15) then (5, 20) is 35, weight 8, but we must check all combinations. Here picking weight 2 then 5 or 3 then 5 is valid.

Key concepts

dynamic_programmingknapsack

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.