String complexity

Правка en2, от rookiegang, 2019-04-22 12:35:24

What is complexity of adding char in front of the string like s = c + s?
Because when I tested on c++ with code, its like O(1), but i think (but not sure then i ask here) i ever submitted at codeforces with this method, in O(n) loop then its get TLE (so the complexity O(n^2)), then i changed that part with other O(1) part then got AC.

What is complexity of adding on string like s = s2 + s1 with s1 is small string with length < 10 and s2 is n-long string?
What is complexity of adding on string like s = s1 + s2 with s1 is small string with length < 10 and s2 is n-long string?

Thank you codeforces community

Теги #strings

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский rookiegang 2019-04-22 12:36:58 4 Tiny change: 'c + s? \nBecaus' -> 'c + s? \n \nBecaus'
en2 Английский rookiegang 2019-04-22 12:35:24 6
en1 Английский rookiegang 2019-04-22 12:34:42 642 Initial revision (published)