Minimum Operations Problem Statement
You are given an array 'ARR'
of size 'N'
consisting of positive integers. Your task is to determine the minimum number of operations required to make all elements in the array equal. An operation can be either addition, subtraction, multiplication, or division performed on any element in the array.
Input:
The first line contains a single integer 'T', the number of test cases.
The first line of each test case contains an integer 'N', the length of the array.
The second line of each test case consists of 'N' space-separated integers representing the array 'ARR'.
Output:
For each test case, output an integer on a new line, depicting the minimum number of operations needed to make all elements of the array equal.
Example:
Input:
T = 1
N = 3
ARR = [1,2,3]
Output:
2
Explanation:
One possible way to achieve equal elements is by incrementing the element with value 1 by 1 and decrementing the element with value 3 by 1, resulting in the array [2,2,2]. This requires 2 operations.
Constraints:
1 <= T <= 10
1 <= N <= 105
0 <= ARR[i] <= 105
- Time Limit: 1 sec

AnswerBot
1y
The minimum number of operations needed to make all elements of the array equal by performing addition, multiplication, subtraction, or division on any element.
Iterate through the array and find the m...read more
Help your peers!
Add answer anonymously...
Wipro Software Developer interview questions & answers
A Software Developer was asked 3d agoQ. What are the OOPS principles in C#?
A Software Developer was asked 3d agoQ. What is an extension method and how do you implement it?
A Software Developer was asked 3d agoQ. What is asynchronous programming?
Popular interview questions of Software Developer
A Software Developer was asked 2mo agoQ1. What languages have you used?
A Software Developer was asked 3mo agoQ2. What are your qualities?
A Software Developer was asked 5mo agoQ3. What is an operating system?
Top HR questions asked in Wipro Software Developer
A Software Developer was asked 1mo agoQ1. Tell me about yourself.
A Software Developer was asked 1mo agoQ2. Tell me about your work experience.
A Software Developer was asked 4mo agoQ3. What is your expected salary?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

