# Check if given array can be rearranged such that mean is equal to median

#include using namespace std;bool binarySearch(float arr[], int size, float key){ int low = 0, high = size – 1, mid; while (low arr[mid]) low = mid + 1; else if (key < arr[mid]) high = mid - 1; else return 1; } return 0;}bool twoPointers(float arr[], int N, float mean){ int i = 0, j = N - 1; while (i < j) { float temp = (arr[i] + arr[j]) / 2; if (temp > mean) j–; else if (temp < mean) i++; else return 1; } return 0;}bool checkArray(float arr[], int N){ float sum = 0; for (int i = 0; i < N; i++) sum += arr[i]; float mean = sum / N; if (N & 1) return binarySearch(arr, N, mean); else return twoPointers(arr, N, mean);}int main(){ float arr[] = { 1.0, 3.0, 6.0, 9.0, 12.0, 32.0 }; int N = sizeof(arr) / sizeof(arr[0]); if (checkArray(arr, N)) cout