Company: DevRev
Difficulty: medium
Minimum Generation Problem Description There is a neural network with n layers where the number of neurons in the i th layer is denoted by layer[i] , for all ( 0 ). In each generation, the system adjusts the number of neurons in a network layer. For all odd generations, 1 neuron is added to at most one layer. Similarly, for even generations, 2 neurons are added to at most one layer. Find the minimum generation in which all the layers can have an equal number of neurons. Function Description Complete the function findMinGeneration in the editor below. findMinGeneration has the following parameters: int layer[n] : the number of neurons in the layers of the network Returns long : the minimum number of generations that can have an equal number of neurons for all layers Examples Example 1: Input: n = 4, layer = [1, 1, 2, 4] Output: 6 Explanation: The 6th generation is the minimum in which all the layers can have an equal number of layers, i.e., 4. The process is as follows: Generation | Sel