You are given an array A of length N. In one operation you can select an index i ( 1 <= i <= N ) and change A[i] to floor(A[i]/2). floor(x) is the largest integer not greater than x.
We want to make all the elements of the array equal. Calculate the minimum number of operations needed to do so.
1 <= N <= 105
1 <= A[i] <= 2 × 109
The first and only argument contains an integer array A of length N.
Return the minimum number of operations to make all the elements of the array equal.
A : [ 3, 1, 1, 3 ]
A : [ 2, 2, 2 ]
We can do an operation on index 1 and 4 to change the array to [1, 1, 1, 1]
All the elements are already same.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.