Back to course home
0% completed
Vote For New Content
Time complexity is O(n^2)
mansidixit989
Jan 9, 2024
The reason is strings are immutable Every time we append a char to a string it is going to create a new copy of string costing O(n) in each iteration
8
0
Comments
Comments
Bruno Ely2 years ago
+1. This could be avoided by appending the characters to a list and joining the list at the end.
L
lejafilip a year ago
Thats why you should firstly resize a result string with input size().
On this page