human
Remove duplicates from a string in O ( 1 ) extra space | Method to remove duplicates.
Table to keep track of visited characters.
To keep track of end index of resultant string.
Driver code"
Solution in Python:
 What is a code to remove duplicates from a string in O ( 1 ) extra space and the other steps required?
assistant
#Here is code to remove duplicates from a string in O ( 1 ) extra space and the other steps required.
 def removeDuplicatesFromString ( string ) :
	table = [ 0 for i in range ( 256 ) ]
	endIndex = 0
	string = list ( string )
	for i in range ( len ( string ) ) :
		if ( table [ ord ( string [ i ] ) ] == 0 ) :
			table [ ord ( string [ i ] ) ] = - 1
			string [ endIndex ] = string [ i ]
			endIndex += 1
	ans = " "
	for i in range ( endIndex ) :
	ans += string [ i ]
	return ans
if __name__ == ' _ _ main _ _ ' :
	temp = " geeksforgeeks "
	print ( removeDuplicatesFromString ( temp ) )