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.
how do you test for time?
great solution bro
You can declare a variable "size" for keeping the word's length.
Using the length() method in a loop may be quite a drag for your pc.
This comment is hidden because it contains spoiler information about the solution
i agree. it kind of kills the point of this kata
Would be a lot better to use StringBuilder, that thing is no joke 100 times faster
No, time complexity is still
O(n * (n + n + n)) = O(n²)
.Concatenating strings with += in a loop can have a time complexity of O(n^2)!!!!
Adding this all together, the overall time complexity is O(n^3).
It has to be one or the other, since all the other values are equal to each other.
I run your in 600+ ms and mine in 260 ms.
I test every value until I find the unique where you sort the whole array.
@kjanus-thecreator Description says. "The tests contain some very huge arrays, so think about performance"
I insist this 6 kyu kata's solution should be implemented in imperative style, not two-lines declarative one. Otherwise it must be 7 kyu.
This comment is hidden because it contains spoiler information about the solution
Isn't this inefficient for large arrays?
it's soo fucking clever man, nice one !
This is not an optimal solution, neither space nor time wise. It's not necessary to sort the arrays or even create any sort of counter list / hash. Instead, its possible to do it with four variables, two to store the different numbers and two to store the counts. A more efficient solution only needs a single O(n) traversal of the entire array at worst, as well as O(1) extra space. Dunno why this is so upvoted but to each their own I guess.
Loading more items...