Tag Archives: array

Find weighted median in matrix

Evolve the problem to 2-dimension array. There is a matrix, m x n. Several groups of people locate at some certain spots. In the following example, there are three groups and the number 4 indicates there are four people in this group. Now we want to find a meeting point in the matrix so that… Read More »

Find the median in an array

Problem: If a random array is [2, 20, 40, 60, 50, 65, 25, 10, 30, 35,  52, 63, 67, 3], find the median of the array. 1. For each new Element in array, if it is less than the root of max heap, put it in the max heap; or put it in the min heap.… Read More »