Skip to content

Instantly share code, notes, and snippets.

@mochow13
Created September 15, 2018 06:24
Show Gist options
  • Save mochow13/97ed57601eb96f6b3640bf2445ea23bf to your computer and use it in GitHub Desktop.
Save mochow13/97ed57601eb96f6b3640bf2445ea23bf to your computer and use it in GitHub Desktop.
// sorted collection
std::vector<int> collection={1,2,5,5,5,6,9,12};
// we are looking for a range where all elements equal to 5
auto range = std::equal_range(begin(collection), end(collection), 5);
// the required range
std::cout<<(range.first-begin(collection))<<" "<<(range.second-begin(collection))<<std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment