Can someone help me with this question? This question is from HackerEarth problem setter intern hiring challenge which is already over.
We are given an array consisting of N elements. We can perform two operations any number of times :
- Make any even element E = E/2.
- Make any odd element E = 2E.
We have to minimize the maximum absolute difference between any two elements
For ex- N=2 {1,2}
We can make 2–> 2/2 = 1 Thus answer = 0.
Constraints:
1<= T <= 500
2 <=N<= 50000
1<= A[i] <= 1000000
Sum of N over all test cases doesn’t exceed 250000.