Company: ibm_11oct
Difficulty: medium
Get Smallest String Problem Description You are given a binary string dataSequence and an integer maxSwaps . The adjacent characters in the string can be swapped at most maxSwaps times. Your task is to determine the alphabetically smallest string that can be achieved by performing at most maxSwaps swaps. Note: A string is said to be alphabetically smaller than another if it appears before it in dictionary order, comparing character by character from left to right. Complete the function getSmallestString in the editor with the following parameters: string dataSequence : the binary string int maxSwaps : the maximum number of adjacent swaps that can be performed Returns: string : the alphabetically smallest binary string after at most maxSwaps swaps. Examples Example 1: Input: dataSequence = "1111100", maxSwaps = 5 Output: "0111110" Explanation: The underlined characters are selected for swapping. An optimal sequence of swaps is shown below: Swap Number Before swapping After swapping 1 11