How to get max integer less than or equal to x in a set ?

Revision en1, by shoya, 2019-06-28 21:14:42

Consider initially an empty set and there are two types of queries:-
1) Given x, insert integer x in the set.
2) Given x, get the max integer y in the current set such that y<=x.

For Example :-
Suppose after several type 1 queries our set is {3,1,-14,1,5}.
Now type 2 comes with x=6 then answer would be 5.
Now type 1 comes with x=6 then set becomes {3,1,-14,1,5,6}.
Now type 2 comes with x=8 then answer would be 6.

How can we solve this problem without using policy based data structure ?

Tags ask, query

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English shoya 2019-06-28 21:14:42 699 Initial revision (published)