You are given a binary string S.
You can perform the following operations on S any number of
times (possibly zero):
• Select an index i such that S[i] is equal to
1 and S[i+1] is equal to 0 for 0 ≤ i < len(S) -1.
• Remove exactly one of the character from S.
Find the smallest string S that you can get after performing
operations on S.
Note:
• If there are multiple smallest strings possible then return the
string which is lexicographically smallest.
Constraints
• 1 <= len(s) <= 10^5
• 1 <= �[�] <= 10^5
Sample Input 1
0000111111
Sample output 1
0000111111
Angel Angel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.