![]() |
VOOZH | about |
Given a binary string s and two integers x and y are given. Task is to arrange the given string in such a way so that '0' comes X-time then '1' comes Y-time and so on until one of the '0' or '1' is finished. Then concatenate rest of the string and print the final string.
Given : x or y can not be 0
Examples:
Input : s = "0011" x = 1 y = 1 Output : 0101 x is 1 and y is 1. So first we print '0' one time the '1' one time and then we print '0', after printing '0', all 0's are vanished from the given string so we concatenate rest of the string which is '1'. Input : s = '1011011' x = 1 y = 1 Output : 0101111
Implementation:
01101101101101101000000
Time Complexity: O(N2)
Auxiliary Space: O(1)