So, we have an array and we have to choose an element and an index. We can make all the elements to its right equal to arr[i] or to the make the right side equals to. to make the left side equal, the cost is i * arr[i]. and to make all elements of right side equal arr[i] , then cost is (n - 1 - i) * arr[i], and we have to calculate the minimum cost to make all elemnts equal.
and one test case that i remember is [5,1,1,2,1,1]
answer is 3.
Comments (1)


