Facebook virtual Round NZ String Question
Anonymous User
490

Problem: Given a binary string S,find another binary string which is not a subsequence of S such that it is lexicographically smallest possible .

Example: 101100
Output: 1001
exp. As 1001 is the smallest string not possible .

Example:101010
Output: 1111

Example: 11
Output:0
Note: leading '0' in the solution string is trimmed like if your answer is 000 then it is simply 0.

|S| can be as large as 1000000
Expected Complexity:O(n) with constant space XD;

Comments (3)