Description
Please write a program that takes a string as input and uses the following steps to check if it's a palindrome using a stack:
請撰寫一支程式,先輸入一個字串,接著使用以下步驟來透過 Stack 檢查字串是否為迴文:
Put the first half of the string into a stack in order.
Continue traversing the string, popping out a character from the stack each time and checking if they are the same.
If all checks are the same, it's a palindrome.
Note: Case sensitivity should be ignored, meaning uppercase and lowercase letters are considered the same.
注意:大小寫視為相同字元
Input
Input contains a string without any spaces in between.
輸入包含一個字串,中間不包含空白
Output
Indicate whether the string is a palindrome or not.
請回答字串是否為迴文。
Sample Input 1
Sample Output 1
AwOo1A1OowA
Yes
Sample Input 2
Sample Output 2
AwwwAA
No
Hint
Please use stack to complete this problem. You can use array or linked list.
請使用stack來實作此問題,可以使用array或linked list來模擬。