human
Write me a code to remove duplicates from string keeping the order according to last occurrences and the other steps required given the following:
Remove duplicates from string keeping the order according to last occurrences | Python3 program to remove duplicate character from character array and print sorted order.
Used as index in the modified string.
Traverse through all characters.
Check if str [ i ] is present before it.
If not present , then add it to result ..
Driver code"
Solution in Python:
assistant
#Here is code to remove duplicates from string keeping the order according to last occurrences and the other steps required.
 def removeDuplicates ( str ) :
	n = len ( str )
	res = " "
	for i in range ( n ) :
		j = i + 1
		while j < n :
			if ( str [ i ] == str [ j ] ) :
				break
			j += 1
		if ( j == n ) :
			res = res + str [ i ]
	return res
if __name__ == ' _ _ main _ _ ' :
	str = " geeksforgeeks "
	print ( removeDuplicates ( str ) )