Tricky Problem

Правка en1, от go_rob, 2017-04-09 15:52:56

You will be given a stream of integers to process, We have to design a data structure which supports Operations like Insertion and Deletion and should work in O(log(n)) time.

And Also we have to find the (MIN GAP) minimum absolute difference between any two integers processed before in O(1) i.e constant time.

We have to design a data structure that supports the above operations.

For Eg. If we have the data 2, 5, 7, 8, Here min gap is 1 (8-7).

But After deletion of 8, the data becomes — 2, 5, 7 and now the Min gap is 2 (7-5) .

And After deletion of 5, the data becomes 2, 7 and now Min Gap is 5.

Note For deletion will be given a key as a parameter, We have to find that key value if present and delete it.

Теги #data structure

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский go_rob 2017-04-09 15:52:56 785 Initial revision (published)