Company: McKinsey_28sept
Difficulty: medium
Equalize It Problem Description You are given an array Arr of N non-negative integers, where N is even. You may perform the following operation any number of times: Choose a number from the array and increase it by 1 or decrease it by 1 . The number must be non-negative after the operation. Calculate the minimum number of operations needed so that exactly N/2 numbers of the array are perfect squares and exactly N/2 numbers are not perfect squares. A perfect square is the square of an integer: 0, 1, 4, 9, 16, ... . In particular, 0 = 0 * 0 is a perfect square. Function Description Complete the function equalizeIt . It takes the following parameters and returns the required answer: N : the length of the array Arr . Arr : the array of numbers. Input Format Read from standard input. T N Arr[0] Arr[1] ... Arr[N-1] ... The first line contains an integer T , the number of test cases. Each test case consists of two lines: the first contains an integer N , the length of the array, and the secon