CJCoding With Joseph
15free / daySign inCreate account

Palindrome Check with a Stack

Write 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 — print one after the last line.

Hints4 available
Topics:
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.