#include #include #include // Required for sort and for_each using namespace std ; bool isPalindrome(const string& str) { if (str.empty()) { return true; // An empty string can be considered a palindrome } int left = 0; int right = str.length() - 1; while (left < right) { if (str[left] != str[right]) { return false; // Characters don't match, not a palindrome } left++; right--; } return true; // All characters matched, it's a palindrome } int main() { vector names = {"chair", "table", "civic", "kayak" }; // Find the palindrome in the vector of strings // TO DO Use a lambda expression instead of the function // auto it = find_if(names.begin(), names.end(), isPalindrome ) ; if (it != names.end()) { cout << "Found: " << *it << endl ; } return 0; }