EyeNewz Tech Get the app

Geeksforgeeks · Technology

Find the Minimum Operations to Equalize Array

Given an integer array arr[], find the minimum number of operations required to make all its elements equal. In one operation, choose two indices i and j such that arr[i] > arr[j], decrease arr[i] by 1, and increase arr[j] by 1. Return -1 if it is impossible to make all array elements equal.Examples : Input: arr[] = [1,

Read original Open in app

Licensed summary · LicensedSummary