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.
Of course, but only after passing them. The idea is to prevent solving the task in a way that only the test cases pass (without solving it generally).
I assume you mean [100, 0] for the quantities (the last brackets)
Unless you are reading the items as [value, size] (they are [size, value]), you are misunderstanding the greedy solution. The greedy solution will always add the item with the highest value-to-size ratio that can fit in the knapsack.
The two ratios here are 1.0 for the [1, 1] item and 1.3 for the [3, 4] item. Therefore, the [3, 4] item will be prioritized. 33 of this item can fit in the 100-size knapsack, taking up 99 of the knapsack. That leaves 1 space for a [1, 1] item to fill.
If you go into "Account Settings" and turn on "CODEWARS LABS" you can post a kumite there...
I had the same problem. If I move numbers generation inside a function it times out(system tests only), but outside a function works in 55ms.
Also, as I've said elsewhere, there are other optimizations to consider aside from just getting your time complexity down.
That being said, you can get away with slower solutions in javascript because it has a proper JIT...
Yeah, can you post it in a kumite?
Fixed it, thank you