Skip to content

Instantly share code, notes, and snippets.

@ilpropheta
Created July 16, 2016 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilpropheta/393d4a40d256048b556fd70bef9c9654 to your computer and use it in GitHub Desktop.
Save ilpropheta/393d4a40d256048b556fd70bef9c9654 to your computer and use it in GitHub Desktop.
const auto lb = lower_bound(begin(sortedVec), end(sortedVec), P);
const auto ub = std::upper_bound(lb, end(sortedVec), P, [](const string& s1, const string& s2){
return s2.compare(0, s1.size(), s1); // s1 is P
});
cout << distance(lb, ub);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment