PerryThePlaytypus's blog

By PerryThePlaytypus, history, 3 months ago, In English

How would I use these functions for pairs? I mean if I have a pair {a,b} and I would like a pair p = {c,d} such that a < c and b < d. The traditional lower_bound and upper_bound functions only give us a pair whose first value 'c' is greater or equal to 'a' and it doesn't care about b and d. Can I get the former in O(logN)?

3 months ago, # |
  Vote: I like it +16 Vote: I do not like it

This is not solvable for lower_bound / upper_bound, because you cannot sort an array that satisfy a < c and b < d for all pairs. You should use Segment Tree instead