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.
The correct way to learn, overall if you're new and don't know some existent methods is asking or searching in the net. You never get the solution just waiting for goddess inspiration, right? In that case I rised the solution almost by myself because of the similitude of Java but I don't know why an identic code that gave me ChatGPT worked when asked why not mine...
Nice
This comment is hidden because it contains spoiler information about the solution
Why am I feeling like this is from chatGPT?
Forgot about a booby trap - dividing null))) With the "for"-loop everything is ok!
make sure you check that n!=0, otherwise you will have an endless loop that would cause the timeout. otherwise, idk either
Is there any difference between importing the library first opposed to doing Math.abs() ?
I wrote same code, but for some reason server timed out, IDK
OMG!Wasted so much time and didn't even think about it! Very clever solution!
I would recommend applying minor amendments for the code to rely on iterators rather than materializing the collections with list() and dict() up front. While the sets are small here so not a real issue in this case, iterators are generally the best practice for efficient memory utilization on arbitrarilly long inputs.
Naturally, you could go further with at least two built-in functions to avoid custom loops but you probably seen this already in other solutions.
Separately, the comments seem reduntant - they basically spell out what can already be clearly seen from the code.
It is not best practice. The same people that go on leetcode that demands more of them and then downvote the problem come here to do their shenanigans and upvote the clever answers and call them a best practice. Bunch of 12 year olds.
Friggen Ninja
Instructions: "Please keep in mind that the test cases ensure that the number of people in the bus is always >= 0".
This comment is hidden because it contains spoiler information about the solution
you don't have to check every time n !== 0 case. if before everything else,if you check !n case and return, you would reduce execution time and redundancy.Also it's not good practice to mutate input.
Loading more items...