This is a verified interview question from Microsoft. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Get Optimal String - Microsoft Online Assessment IGDTUW" covers key patterns like Arrays.
"Given a binary string s, form a new string b as follows: * String b is initially empty. * For each position i (0 <= i < length of s): * Append s[i] to the end of b * Reverse the string b Before creating b, reorder s to produce the lexicographically maximum possible b. Determine the permutation of s that generates the maximum possible b. Example Input: s = "011" Reorder s from "011" to "101". String b is formed as follows: | Operation | Append | Reverse (b after) | |---|---|---| | 1 | 1 | 1 | | 2 | 10 | 01 | | 3 | 011 | 110 | Output: "101"  > Explanation: Returning "101" represents the permutation of s that generates the maximum possible b (which ends up being "110"). > Constraints * 1 <= length of s <= 100,000 * The string s consists only of characters '0' and '1'."
Join thousands of developers practicing for Microsoft.