What is the runtime of your solution?
sizes = {25,50,60,120} maximum = 130Your method will return 120 since all other combinations of components either produce less code, or are greater than the 130 limit. If no software can be built return -1.
Definition
int[], int
int
int biggest(int[] sizes, int maximum)
Constraints
Examples
{1,2,3,4,5} 15Returns: 15
All of the code can be used
{20,40,45,60,60} 86Returns: 85
Using 40 and 45 will produce the largest amount of code.
{89,73,20,5,5,10000,900} 995Returns: 994
{122} 1Returns: -1