← Back to STL Containers
Question 521
Palindrome Check with a Stack
Palindrome Check with a Stack
Write a functionbool isPalindrome(const string& s)that uses astack<char>to decide whethersreads 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 printtrueorfalseon 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 — 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.