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.
Nope, this is not O(n^2). Just O(n) with a large coefficient (36, when corrected for digits).
Could you explain how this is O(n^2)?
But its less readable. Nice trade to discuss hahaha
I agree! Although the top voted solutions are very nice and compact, they offer a slower time complexity.
Duplicate, not actionable.
'Sok, buddy, I did the same thing.
I think time & space complexity should be checked in tests.
Like in codility.
It is pretty important "how" user solves the task not only "if".
I'd say that the addition of a "Fastest" category could cover that but then where do you stop? Do you add "Shortest"? Or what about a "Shortest and Fastest" category and then a "Cleverist and Fastest but not Shortest" category? If the Clever and Best Practices categories were used correctly I think we'd just about have it covered.
That is more readable than no spaces.
This comment is hidden because it contains spoiler information about the solution
Warning personal preference ahead! Your lack of whitespace makes your solution hard to read.
Poorly worded explanation. There are many grammatical errors.
I quite
I love codewars! It's a great site. I'd like to focus on voting on solutions. Right now we have two upvoting options "Best Practice" and "Clever". I feel these categories miss a very important aspect of solving algorithms -- time and space complexity.
Many solutions with poor time or space compexity are often voted up because they are one-liners. If an algorithm can be solved in 1 line but have
O(n)
space complexitiy (eg allocating an n-sized array) vs 2 lines and haveO(1)
space complexity (eg a single counter variable), then the 2 line solution should be voted to the top.We could use the existing voting options to vote-up algorithms with better time or space complexity. But maybe this is an opportunity to reconsider what we care about in regards to solving algorithms.
Do we care if a solution is "Clever" or more vaguely a "Best Practice"? Or do we care about code readablity, time complexity and space complexity?
Also we can put actual numbers on the complexities, instead of voting we can rate an algorithm with it's Big O notation.
O(1), O(n), O(n^2), .. etc
Love it
Loading more items...