A student just learnt the reverse() function in c++ STL. He writes the following algorithm to check if a given string S is a palindrome.
bool isPalindrome(string& s)
string rev = s
reverse(rev.begin(), rev.end())
return s == rev
Is the algorithm correct? What is the space and time complexity?
whyans is d