Created
September 15, 2018 06:01
-
-
Save mochow13/6dc0b1beb93568dea42fcf85befb2024 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<int> collection={1,2,13,5,12,3,4}; | |
auto median_pos=collection.begin()+collection.size()/2; | |
std::nth_element(begin(collection),median_pos,end(collection)); | |
// note that the original vector will be changed due to the operations | |
// done by nth_element |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment