Space complexity

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?
why is space complexity o(n)

@praritv1 To be very honest, I was not able to find a good source where I could get the space complexity of the same. I even read the documentation of std::reverse() on cplusplus. com but I was not able to find the answer. It would be unfair on my part to give you any verdict for the same.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.