My code needs to get string from user and check if it is consisting of its reverse. Do I need to use stack? if yes why? I mean why we need to use stack to check 1D array if its first n letters are reverse of last n letters?
like array is: abcddcba
How can I use stack to check if abcd is reverse of dcba?
Can someone let me understand what stuck really need to do here?
I already wrote some code but need some explanation to finalize it...
add every letter in a stack than check every letter again with the letter on top of the stack and pop the stack, if every letter matches than that word is a reverse
so for the word abcba the stack would be
a(last a)
b(last b)
c
b(first b)
a(first a)
and if you get the letters from top o bottom the word is the same so its a reverse