Company: HackerEarth_Intern_6aug
Difficulty: medium
Array-Difference Problem Description Mark has an array of N elements of positive integers. He is interested in finding out the maximum absolute difference between any two elements in the array. But he wants to minimize the maximum absolute difference. He can perform the following two types of operation on the array elements any number of times. If the element E is even then he can replace it by E/2 If the element E is odd then he can replace it by 2E Can you help him minimize this maximum absolute difference? Input Format: The first line consists of a single integer T, the number of test cases. Each test case consists of 2 lines, 1st line has an integer N, the number of elements in the array. Next lines have N space separated integers, denoting array elements. Output Format: For each test case, output in a separate line, the answer to the given question. Examples Example 1: Input: 1 2 1 2 Output: 0 Explanation: He can make 1 as 1*2 = 2. So array becomes [2, 2]. Min(max absolute diff) h