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 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.
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's soo fucking clever man, nice one !
Yes
too slow...
"If you use an array to store the number of occurances …"
it sound to me like a histogram, and for that a hash map would be a better data structure.
Will it work with string containing only one cymbol?
beautiful
This is some beautiful code!
I agree this is a cool solution but far from following best practices. Runtime complexity for this solution is O(N^2) which can easily be solved in O(N)
Cool solution!
Clever solution, but you should use here StringBuilder object to create final string for better performance.
TIL that lastIndexOf exists and I've looked at the String API dozens of times haha