Math, asked by Munazermir7843, 11 months ago

Given an array min number of activities to make all elements equal

Answers

Answered by cuteprincess69
0

Minimum operation to make all elements equal in array

Given an array with n positive integers. We need to find the minimum number of operation to make all elements equal. We can perform addition, multiplication, subtraction or division with any element on an array element.

Input : arr[] = {1, 2, 3, 4}

Output : 3

Since all elements are different,

we need to perform at least three

operations to make them same. For

example, we can make them all 1

by doing three subtractions. Or make

them all 3 by doing three additions.

Input : arr[] = {1, 1, 1, 1}

Output : 0

Similar questions