Given a string of ‘a’ and ‘b’ only
for example
string is ‘baaab’ and x=3 and y=3
Find the lexicographical smallest permutation of string that contains
count of sub-sequence ‘ab’ = x times and count of sub-sequence ‘ba’ = y times.
For above example , there is a possible permutation ababa
We can print -1 , in case if its not possible
for example when string is ‘abbb’ and x = 3 and y = 3.
For this example no permutation is possible
What logic will you use ?