Pregunta de entrevista de Ritual

Given a Integer stream, 1. find medium element (when sorted) and 2. insert element. Need to optimize for time.

Respuesta de la entrevista

Anónimo

17 ago 2017

Create two heap. One max and one min. Put half of the stuff on one heap and rest to the other. then if both heaps have same number of elements, return average of first element of both heaps, else return first element of heap with most elements.