human
Reverse a string preserving space positions | Function to reverse the string and preserve the space position.
Mark spaces in result.
Traverse input string from beginning and put characters in result from end.
Ignore spaces in input string.
Ignore spaces in result ..
Driver code"
Solution in Python:
assistant
#Here is code to reverse a string preserving space positions and the other steps required.
 def reverses ( st ) :
	n = len ( st )
	result = [ 0 ] * n
	for i in range ( n ) :
		if ( st [ i ] == ' ▁ ' ) :
			result [ i ] = ' ▁ '
	j = n - 1
	for i in range ( len ( st ) ) :
		if ( st [ i ] != ' ▁ ' ) :
			if ( result [ j ] == ' ▁ ' ) :
				j -= 1
			result [ j ] = st [ i ]
			j -= 1
	return ' ' . join ( result )
if __name__ == " _ _ main _ _ " :
	st = " internship ▁ at ▁ geeks ▁ for ▁ geeks "
	print ( reverses ( st ) )