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.
Smells like premature optimisation in here.
I know String concetenation is bad but never thought it'd add to time complexity. Saw this thread, it might come handy: https://www.reddit.com/r/learnprogramming/comments/4uh2b6/java_how_is_the_running_time_of_string/
this is bs. its O(n)
can u explain how concatenation make it O(n^2)
That's because it copies whole string on every iteration. It would be O(n) if you used
StringBuilder
.Wait how is this O(n^2) its only 1 for loop? I had a similar solution using if/else instead of tenary but I am also running O(n) Time complexity
The purpose is to finish in one line, not to be readable. I think it's funny.
Bad solution! Time complexity is O(n^2), while there are more than one linear complexity solutions.