Problem Statement:
Developers at Amazon are creating a single sign-on application for the web apps in AWS. In one of its modules, a security code is in the form of a binary string that changes every minute.
The characters at a pair of indices i and i+1 are swapped such that the resulting code is the lexicographically maximum binary string that can be achieved in this step. If it is not possible to make the code lexicographically greater, then the code does not change.
String x is lexicographically greater than string y if either y is a prefix of x (and x != y), or there any i exists such that (0 <= i < min(|x|, |y|)), that y_i < x_i and for any j (0 <= j < i) x_j = y_j. Here, |a| denotes the length of the string a.
Given the string initialCode, the initial security code, and an integer minutesElapsed, find the security code after minutesElapsed minutes.
Example:
(The number of times the code changes is equal tominutesElapsed).