Time complexity of string operations

shape