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.
Actually, it's a kind of method name contains
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
Bad solution! Time complexity is O(n^2), while there are more than one linear complexity solutions.
I know. It's most likely not the solution one is looking for when declaring it final. I still am very new to the game, but back then i was glad to get a "green light". :D
Am I the only one to think it's funny that
arr
is declaredfinal
and the method manipulates its contents?nice explanation. I saw it by finding a pattern in the lines and comparing. But it took me a while. Great to now understand the mathematical approach!!