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 believe performance is always the main concern; it isnt about looking cool and getting it in one line; that is clever yes but not best practice; best practice means most efficient and clear and scalable (which means if you want to add or remove a aspect of the code you dont have to rework on all aspects of the code only the aspect you want to) ALWAYS!!!!
why isn't it necessary to cast to int?
What qualifies as "best practice" depends on the context. When performance is a concern, yes, an O(n) solution is best practice. When performance is not a concern, clarity and maintainability is best practice. Performance is generally not a concern when the potential number of items results in little or no discernable delay in processing. To be fair, though, I find this solution to be neither fastest nor clearest. I think what the author was going for was "most succinct."
This comment is hidden because it contains spoiler information about the solution