I recently came to the solution of the palindrome problem, but I do not understand how this part of code works (with rbegin and rend). Can someone explain it to me?
#include <iostream>
#include <string>
using namespace std;
bool checkPalindrome(string);
int main()
{
string inputString = "palindrom";
cout << checkPalindrome(inputString);
return 0;
}
bool checkPalindrome(std::string inputString)
{
return (inputString == string(inputString.rbegin(), inputString.rend()));
}
See Question&Answers more detail:os