LeetCode 462: Minimum Moves to Equal Array Elements II
A clear explanation of why the median minimizes the number of moves needed to make all array elements equal.
8 notes
A clear explanation of why the median minimizes the number of moves needed to make all array elements equal.
A median-based solution for minimizing total Manhattan distance in a grid.
A detailed explanation of finding the median of two sorted arrays using binary search over partitions.
Maintain the median of a sliding window using two heaps while the window moves over a stream.
Select the upper median, the element at index floor(n/2), using selection or partitioning.
Select the lower median, the element at index floor((n-1)/2), using selection or partitioning.
Maintain the median of a stream using a max heap and a min heap.
Find the middle value of a collection in linear time using selection algorithms, without the overhead of a full sort.