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.
I have tried something similar (but less elegant), however this algorithm does not pass the test with the dataset:
customers {100, 90, 90, 60, 50}
n 2
this algorithm return 210 (100+60+50 = 210 vs 90 + 90 =180)
but true result: 200 (100 + 90 = 190 vs 90 + 60 + 50 = 200)
correct me, if i am wrong. This solution takes n^2 running time due to for each customer, this program is finding the register by checking each register's least. Space-wise, it is O(n) where the n is the number of registers.
There are specifications:
So a (silly and absurd) input of a negative queue will never happen.
Very nice! However, it will crash when (n <= 0).
it is so beautiful and I am superised that my code is similar to this solusion ,I'm just a noob guy here XD
For those unfamiliar, the problem is also known as "Bin Packing". I was very suprised but the simplicity of solution, when I first heard about it as well :D