I have with myself n
integers. I am given with starting value(SV)
and ending value(EV)
, I need to delete the values that lie within the range of these values. The starting value as well the ending value may not exist in the set of n integers. This I need to do in O(No. Of elements deleted)
. Container such as vector
of integers is failing since I need to B.Search and get the iterator that is greater than equal to the SV
and for EV
as well which takes an additional time of Log n
. Any approach appreciated.
Edit : I was even thinking of using maps, storing the values as keys, and erasing on the basis of those key values. But the problem again is that the operation lower_bound
and upper_bound
occur in log
time.