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.
Still O(n) time complexity as args.Min() has to iterate through the whole string in worst case similar to a for loop
Are u serious? I`m gonna practice more...
Another opportunity to practice with LINQ (◕‿◕)
I agree Clever flag is more appropriate. But this shows again that Best Practise and Clever don't mean that much. Perhaps a single Upvote button is better.
I disagree. Using a system function to cast the number to string, when bit operations can be used to determine if a bit is set (which is the whole purpose of these operators), is using a rocket launcher to me. The count operation additionally has to view every element.
Bitwise checks are mostly done, where performance has to be considered. This is why I disagree on this solution being best practice for this particular task.
Besides, if you'd found this line of code, without the method name, most folks would still not recognize that it counts bits.
Don't get me entirely wrong, I still think this solution is creative, since is solves the task with minimal effort. I just can't agree on this being best practice.
This is not less rocket launcher than your solution (and not really more than any other one).
I'm not sure why so many think this is elegant and considered to be a best practice.
You should not shoot with rocket launchers at birds.
okay don't need to complain about the solution actualy obviously that's a basic question so it doesn't matter how you solve it
For all discussing performance over readability... Usually, the piece of highly optimized code is never read nor changed after it works. One may hide it somewhere in a helpers folder and you ain't gonna see it. So it depends on what you need.
Depends on how frequently it's used, and to what degree performance matters.
Isn't the purpose of the exercises to see how you handle certain situations? If this a way to do it, why not do it?
Clever but slow.
Lol. My solution was quite similar.
I think I'm finally getting the hang of best practices.
Genial
so ez
Loading more items...