human
What is a code to lexicographically smallest string formed repeatedly deleting character from substring 10 and the other steps required given the following:
Lexicographically smallest string formed repeatedly deleting character from substring 10 | Function to find smallest lexicogra - phically smallest string.
Stores the index of last occuring 0.
Stores the lexicographically smallest string.
Traverse the S.
If str [ i ] is 0.
Assign i to lastZe.
Traverse the str.
If i is less than or equal to lastZe and str [ i ] is 0.
If i is greater than lastZe.
Return ans.
Driver Code.
Input.
Function Call"
Solution in Python:
assistant
#Here is code to lexicographically smallest string formed repeatedly deleting character from substring 10 and the other steps required.
 def lexicographicallySmallestString ( S , N ) :
	LastZe = - 1
	ans = " "
	for i in range ( N - 1 , - 1 , - 1 ) :
		if ( S [ i ] == '0' ) :
			LastZe = i
			break
	for i in range ( N ) :
		if ( i <= LastZe and S [ i ] == '0' ) :
			ans += S [ i ]
		elif ( i > LastZe ) :
			ans += S [ i ]
	return ans
if __name__ == ' _ _ main _ _ ' :
	S = "11001101"
	N = len ( S )
	print ( lexicographicallySmallestString ( S , N ) )