Company: Capital One_1july
Difficulty: medium
Resource Conversion Process Problem Description You are given an array of resources, with each being an "A" or "P". All "A"s are arranged at the beginning of the array and "P"s stand at the end. A process is executed on this array until it halts. You are given a variable conversionRate , which represents the number of "P" resources that can be deleted and exchanged for one "A" resource. Each cycle, one of the three events happens: Option 1: If there are at least conversionRate "P" resources, then the last conversionRate "P" resources are removed and one "A" is added at the beginning of the array; Option 2: If there is at least one "A", the last "A" changes to "P"; Option 3: If neither Option 1 nor Option 2 can be completed, then the process halts. Follow the process and compute how many cycles will pass until the process halts. Refer to the examples below for better understanding. Note: You are not expected to provide the most optimal solution, but a solution with time complexity not w