 New update is available. Click here to update. Close
Topic list
Make the Equal
MEDIUM
30 mins
Greedy
Topics (Covered in this problem)
Problem solved
Skill meter Greedy
-
-
Other topics
Problem solved
Skill meter Strings
-
- Matrices (2D Arrays)
-
- -
- Sorting
-
- Binary Search
-
- Stacks & Queues
-
- Trees
-
- Graph
-
- Dynamic Programming
-
- Tries
-
- Arrays
-
- SQL
-
- Binary Search Trees
-
- Heap
-
- Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Make the Equal

Contributed by
Medium 0/80
Avg time to solve 30 mins
Success Rate 34 % Share 0 upvotes

## Problem Statement

#### The task is to get all elements equal in the minimum number of operations.

##### Example:
``````Input: ‘N’ = 3  ‘ARR’ = [1, 2, 3]

Output: 2
In the First operation we can increase the numbers at index 0, and 1 by 2 which makes the array [3, 4, 3].
In the second operation we increase the numbers at index 0 and 2 by 1 which makes all the elements to [4, 4, 4].
It is the optimal answer and there is no other optimal solution.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images ) ##### Sample Input 1 :
``````2
3
1 2 3
5
5 5 5 5 5
``````

##### Sample Output 1 :

``````2
0
``````
##### Explanation Of Sample Input 1 :
``````For the first test case:-
In the First operation we can increase the numbers at index 0, and 1 by 2 which makes the array [3, 4, 3].
In the second operation, we increase the numbers at index 0 and 2 by 1 which makes all the elements [4, 4, 4].
It is the optimal answer and there is no other optimal solution.

For the second test case:-
All the elements of the array are already equal so there is no operation required.
``````
##### Sample Input 2 :
``````2
10
13 15 9 7 12 7 12 11 6 12
7
12 7 12 14 8 6 14
``````
##### Sample Output 2 :
``````16
12
``````  Auto Console