c++ - binary search a std:map -
using c++, if have n
integers in std::map
, possible efficiently search largest element smaller k
in std::map
?
for example have {1, 3, 5, 6}
, k
4 returned value should 3
i know std::map
can search in log(n)
, if exact match.
use lower_bound
, decrement returned iterator one.
Comments
Post a Comment