Question: write code for this question in java Santa and Banta are playing a game with numbers. Santa wrote N numbers on a piece of paper
write code for this question in java
Santa and Banta are playing a game with numbers. Santa wrote N numbers on a piece of paper and gave it to Banta. He further asks Banta to make all numbers equal. Now Banta can replace any ith number with any other number M but then he has to give abs(Alil-M) dollars to Santa. Now Banta wishes to minimize the total amount he has to pay to make all the N numbers equal so he must choose M wisely. Can you help Banta by calculating the minimum amount he has to pay to Santa. Input First line of input contains Tie number of testcases. First line of each test case contains Ni.e number of numbers Next line contains N numbers separated by a space
constraints :
1<=1<=10 ^ 4 1<=N<=10^5 1<=Ali] <=10^9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
