Kindly give some hint about the solution

Kindly give some hint about the solution

Careful observation here is that you decrease a particular element by 1 and add 1 to any adjacent neighbours(if it exists,eg A[0] has only one neighbour which is A[1]), so this way your sum of all elements is constant. Now for all elements to be equal, the average of given elements should be integer(example for N=3,A= (1,1,2 )has no possible answer as average is 4/3 which is not an integer). Now if average is integer, think upon making each element equal to this average.

Thanks but these steps i already observed and was there in the videos covered by Prateek Bhaiya as well.


refer page 11 of this.

In load balancer problem , the processor can share 1-1 load to each of its neighbours … and this was counted as 1 operation but here the element can be subtracted once and that can be shifted to one of the elements, so this question is a bit different from the load balancer problem. An d thtat’s why i wish to know what changes are to be made in the approach?

Actually the question is same and there is some error in problem statement, the answer in sample case is same according to load balancer!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.