Company: Visa (Associate SW Engineer) off campus_17march
Difficulty: medium
Question 2 You are given an array computationalTime of length n , where computationalTime[i] is the computation time of the i th neural network layer. You may perform the following operation any number of times: Choose an even value c that appears in the array For every layer with computation time exactly c , replace it with c / 2 Determine the minimum number of operations required so that all layers have odd computation times. Example Suppose n = 4 and computationalTime = [2, 4, 8, 16]. Output: 4 The optimal approach is: Choose c = 16 and reduce the computation time of layer 4 to 8. Thus, computationalTime = [2, 4, 8, 8]. Choose c = 8 and reduce the computation time of layers 3 and 4 to 4. Thus, computationalTime = [2, 4, 4, 4]. Choose c = 4 and reduce the computation time of layers 2, 3, and 4 to 2. Thus, computationalTime = [2, 2, 2, 2]. Choose c = 2 and reduce the computation time of all the layers to 1. Thus, computationalTime = [1, 1, 1, 1]. There were four operations applied. Co