Created
February 24, 2017 06:29
-
-
Save hikilaka/a3dba34ac3f09db21680a6f0acc167d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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<std::string> allLongestStrings(std::vector<std::string> inputArray) { | |
auto begin = std::begin(inputArray); | |
auto end = std::end(inputArray); | |
auto longest_length = std::max_element(begin, end, [](auto a, auto b) { | |
return a.size() < b.size(); | |
})->size(); | |
inputArray.erase(std::remove_if(begin, end, [&](auto s) { | |
return s.size() != longest_length; | |
}), end); | |
return inputArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment