Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
ah sorry, marked as resolved
Mostly fixed!
Fixed!
That's right
This solution is also in pseudo-polynomial time but it is optimized using bitwise operations, which makes it 64 times faster. Try to figure out why it works! :D
This comment is hidden because it contains spoiler information about the solution
I don't think a greedy solution would work here... Consider arr = [3,6,7,9] and K = 10, a subset would be {7,3}. Let's look at all the conditions in your for loop:
len(res) != 0, so the first condition fails
total != 0, so the second condition fails
total - res[-1] (10 - 9) > 0, so the third condition (if) fails
total - res[-1] (10 - 9) != 0, so the third condition (elif) fails
Now from your else, total = 10 - 9 = 1
Since there is no 1 in the original array, your code will loop through the array and incorrectly output False.
Is it okay now?
Changing var to let fixed it.
Sorry i'm still quite unfamiliar, but how would input modification affect?
Thanks for the suggestion, now answers will be returned as BigInt.
Done. though i'm not sure where to use find_a(j[:],i)? Do i use it as the function?
I've checked that they're not the same every time?
They should not the same every time. i've reduced to 100 random cases.
Changed the answers to string notation.
Loading more items...