Heap is really not good solution in this situation. it does not help the algorithm become all that much more efficient. Using a heap instead would barely show significant gain in performance, bar certain very narrow situations. Using heap here to reduce from O(2n) to O(n), while using a loop is already so elegant and simply, is impractical (in most cases), in short.
That being said, while this solution is elegant, some understanding of time and space complexity is required for beginners to make the most of it. Blindly following code shortening practices is not good software engineering practice.
Thanks for the approach I couldn't come up with on my own.
My code went for about 20 lines and still failed most of the test cases. This is just a brilliant way to solve this wow.
I was going to say something similar, it's much more efficient to leverage a heap. Not nearly as pretty tho
This is simply brilliant!
One of the benefits from learning any programming language. Keep things simple...
i got brain damage from this kata.
I cant belive it could be solved with only four lines...
Learned something new tho. I didnt know you could modify lists like this +=
handy tool. thx!
I spent 2 days for getting the solution 😢
it took me a moment :D
This is not a good solution. Using .index method to find an index of the minimal value is Pythonic and looks smart but it is vary slow as we have to loop over the 'l' list two times for every customer. It's better to use a single loop to find an index of the lowest value.
Wow that's actual genius🙀🔥
This solution make my day :) awesomee work
Actually, this is disgusting...
This comment is hidden because it contains spoiler information about the solution