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.
yeah actually you needed to define only the first 2 terms of sequence rather than all the sequence. However, I liked how you used memoization
Alr, could've probably guessed that but being more sure is always nice. Thx :D
One-time math calculations are normally
O(1)
, although it depends on how they are implemented.When I first saw this, I was like what??!! :D
Probably a 6
What kata rank would you give this one (for Python)?
face => palm
It's not cheating. It's Python.
What an ingenious way!!!
Yes, it's O(n^2): you're using a single loop over O(n^2) instead of two nested loops over O(n) both with common complexity of O(n^2). Also, probably it's not so effective because it's using additional checks instead of just using built-in loops (but this should be benchmarked, not speculated), and it's much less readable; but it has the same time complexity.
a*(a+1) = n*n
Ok, if you say so, what is the time complexity of my own code since maybe i don't really know about time complexity
The task is to generate O(n^2) elements. You can't do O(n^2) work in less then O(n^2) steps.
Bad practice O(n^2)
Because originally it is a Ruby kata, and it's pretty much using a built-in. The kata's rank is shared amongst all languages.
Loading more items...