Company: Citadel SDE intern_28april
Difficulty: medium
A neural network has n layers, where the number of neurons in the i th layer is layer[i] . In each generation, the system adjusts the neurons as follows: In odd generations: 1 neuron can be added to at most one layer In even generations: 2 neurons can be added to at most one layer Find the minimum generation in which all layers can have an equal number of neurons. Example n = 4 layer = [1, 1, 2, 4] Table of Generations Generation Selected Layer Updated Layers 1 1 [2, 1, 2, 4] 2 1 [4, 1, 2, 4] 3 2 [4, 2, 2, 4] 4 2 [4, 4, 2, 4] 5 None chosen [4, 4, 2, 4] 6 3 [4, 4, 4, 4] The 6 th generation is the minimum in which all the layers can have an equal number of neurons, i.e., 4. Function Description Complete the function findMinGeneration in the editor with the following parameters: int layer[n] : the number of neurons in the layers of the network Returns long : the minimum number of generations until all layers can have an equal number of neurons Constraints 1 ≤ n ≤ 10 5 1 ≤ layer[i