Ropes Data Structure ( Fast String Concatenation ) | Function that concatenates strings a [ 0. . n1 - 1 ] and b [ 0. . n2 - 1 ] and stores the result in c [ ] ; Copy characters of A [ ] to C [ ] ; Copy characters of B [ ] ; Driver Code ; Concatenate a [ ] and b [ ] and store result in c [ ]
def concatenate ( a , b , c , n1 , n2 ) : NEW_LINE INDENT i = - 1 NEW_LINE for i in range ( n1 ) : NEW_LINE INDENT c [ i ] = a [ i ] NEW_LINE DEDENT for j in range ( n2 ) : NEW_LINE INDENT c [ i ] = b [ j ] NEW_LINE i += 1 NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT a = " Hi ▁ This ▁ is ▁ geeksforgeeks . ▁ " NEW_LINE n1 = len ( a ) NEW_LINE b = " You ▁ are ▁ welcome ▁ here . " NEW_LINE n2 = len ( b ) NEW_LINE a = list ( a ) NEW_LINE b = list ( b ) NEW_LINE c = [ 0 ] * ( n1 + n2 - 1 ) NEW_LINE concatenate ( a , b , c , n1 , n2 ) NEW_LINE for i in c : NEW_LINE INDENT print ( i , end = " " ) NEW_LINE DEDENT DEDENT