Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Solve the knapsack problem using dynamic programming.

Hard

Problem Statement

Solve the knapsack problem using dynamic programming.

Sample Input

Weights: [1, 3, 4, 5]; Values: [1, 4, 5, 7]; Capacity: 7

Sample Output

Maximum Value: 9

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
using System; class Knapsack { static void Main() { // Solve the knapsack problem using dynamic programming } }
Log in or sign up to run or submit your code.Log inSign up
Input
Weights: [1, 3, 4, 5]; Values: [1, 4, 5, 7]; Capacity: 7
Expected Output
Maximum Value: 9