Company: Amazon Sde1 ftc_21april
Difficulty: medium
Your project team needs to work closely with a group of software testers. They have requested that your team create an array generator service to assist with testing software functionality. Create an array generator service. Its input parameters are: values[n] contains n positive integers. state is a string that contains n characters. Each character is a '0' or '1'. If state[i] = '1' , values[i] is available. If state[i] = '0' , values[i] is blocked. To create an integer array, S , the following operation is performed exactly m times. S is initially empty. Choose any values[i] that is available, that is, where state[i] = '1' . The same element can be chosen any number of times. Append the value in values[i] to S . For all state[i] = '0' such that state[i-1] == '1' or state[i+1] == '1' , update state[i] to '1'. For example, if state = '0100101' before the operation, it equals ' 1111111 ' after the operation. Find the lexicographically largest sequence S that can be obtained after m oper