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.
You have a very weird opinion regarding someone's ego. I guess exactly you show off here
I presumed the O(n*log(n)) solution wouldn't even be allowed.
FArekkusu's brain be like;
O(n) speed < O(n log n) : n <= 1
XD
This comment is hidden because it contains spoiler information about the solution
And what's the point of this? There's a
O(1)
solution.Thank you. I just saw this yesterday, and remembered when I coded, but forgot when I got here.
(I thought I was wrong, but I was mistaken.)
@grassworm: why are you using parseInt on a number if you wanna avoid string conversions...?!? XD
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
The function you're using is
O(1)
only as long as the input is small enough for CPU to calculate it inO(1)
, for arbitrary-sized integers you'd still fall back to some hand-made implementation which would be slower than that.Except
O
implies infinitely big inputs. When everything is so small, time complexity may not be a correct estimation of how fast the code actually is. On CW your solution is twice as slow as using strings.Ok, thanks for the explanation. Javascript won't work with a trillion digits ^_^ but I get the idea.
This comment is hidden because it contains spoiler information about the solution
A native
O(n * log(n))
solution will be a lot faster than any PythonO(n)
solution you can come up with (unless the lists include billions of elements, maybe more). And your implementation is not even good.O(n * (length of the alphabet)) though.
Not my definition of linear.
are you saying that O(n) is slower than O(n log n)...? XD
lol...
sure, the other one will be faster on the fields, because it uses builtins, but the asymptotic behavior, on the other hand...
Only because the top answer is
O(n^2)
. This solution is a lot more efficient.Fixed