@yanggao said in 14ms java solution:

I am not very clear about why the opt point should be median. Can someone give some proof, mathematically, that shows that median is the optimal solution given both odd-length array and even-length array

Same thought process as in - https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/

Go to the median.