Company: Autodesk SDE intern on campus_9april
Difficulty: medium
You are given a binary array state made up of the integers 0 and 1 . You are also given operations - an array of strings, where each string is one of two kinds of operation: "L" - locate the smallest index i for which state[i] = 0 , and set state[i] = 1 . If no such index exists, do nothing. "C{index}" - set state[index] = 0 . This happens regardless of what state[index] held beforehand. It is guaranteed that index is a valid 0-based index of state (ie: index < state.length ). Given state and operations , return the binary string formed by state once every operation has been applied. Example For state = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] and operations = ["L", "L", "C0", "L", "C3"] , the output should be solution(state, operations) = "1100000000" . The state starts out as [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] . For the 1 st operation "L" , the smallest index with state[i] = 0 is i = 0 . Afterward, state is [1, 0, 0, 0, 0, 0, 0, 0, 0, 0] . For the 2 nd operation "L" , the smallest index with st