I understand that median element is calculated based on index/total number of elements in an Array while Average is based on total value of the array. I am trying to solve the question : Given an integer K and a matrix of N rows and M columns, the task is to find the minimum number of operations required to make all the elements of the matrix equal. In a single operation, K can be added to or subtracted from any element of the matrix.
Which element we should take here (to which all the elements will be made equal) and why?