Palindrome Check with a Stack
mediumQuestion 521Write a function bool isPalindrome(const string& s) that uses a stack<char> to decide whether s reads the same forwards and backwards. The check is case-sensitive and every character counts (do not skip spaces or punctuation). The empty string is a palindrome.
The tests print true or false on its own line for each string tested. For "racecar" the output is exactly what is shown in Expected Output.
Do NOT write a main function.
Expected output
true false true
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
STL ContainersStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.