We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Dynamic Programming
- Knapsack
- Discussions
Knapsack
Knapsack
Sort by
recency
|
264 Discussions
|
Please Login in order to post a comment
For JavaScript is also needed to fix the main.
As people have already stated, there are errors in the way the problem was formulated, but it is still solvable. This was my inneficient but workable C# solution:
Annoyingly ... we hade to update the main function to get the code to loop through all test cases ... shoulda put that in the instructions.
I had the same issue in C++ 14
I agree. so annoying. hackerrank is retarded
Python: you need to FIX THE MAIN!
It should be:
Resolution:
solution using C with recursion function. What I did here is to try to get every possible combination in an optimal way because there is no other way to know the highest possible sum because there are no limits on the numbers used to get this sum. So for each element in the array, start from the first index and get the maximum sum using it. Store this sum, and each time, reduce this sum by the value in the specific index. and pass this sum to the next index. and do it recursively for all indexes.
for main function issues, just do a for loop t times from
char** first_multiple_input = split_string(rtrim(readline()));
untilfprintf(fptr, "%d\n", result);
the code :