Challenge: Maximum Amount of Gold

Solve the Maximum Amount of Gold Problem.

We'll cover the following

Problem


Maximum Amount of Gold Problem

Given a set of gold bars of various weights and a backpack that can hold at most WW pounds, place as much gold as possible into the backpack.

Input: A set of nn gold bars of integer weights w1,,wnw_{1},\ldots, w_{n} and a backpack that can hold at most WW pounds.

Output: A subset of gold bars of maximum total weight not exceeding WW.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.