@alanwang I think this is actually the best explanation for the algorithm.
Posts made by Longstation
RE: Explanation of "Super Easy Java Solution Beats 98.8%" from @pinkfloyda
RE: 20 line O(log(k)) solution with clear explanation & illustration
If the total size of the array was even, then we know that the result would be the average of the middle two numbers (where k = totalLength/2, k & k + 1).
Should it be k - 1, k? For example, if I have [1,2,3,4]. totalLength = 4, and k=2. But the actual indices are 1 and 2, not 2 and 3.
Update: ok, the op is using 1 based array.