Here's Find a Palindrome, one of the classic tasks of computer science. A palindrome is a word or sentence with the same order of characters in both directions (for example, the word pop is a palindrome, but the word push is not; it will be the hsup word in the other direction). Try to solve it using stack and queue.
Note that the
Stack and Queue structs are already declared and set up to store rune values for this task.Don't think about how to read the input and return an answer, focus on the task. If you are stuck, welcome to the HINT section.
- Tip: fill the
Stackstructure and theQueuestructure with aPushfunction; - Tip: start to
Popvalues from structures; - Tip: the
Stackwill get values from the end of thestorage; theQueuewill get from the start; - Tip: if one of the structures returns an error, it means chars is over, and the word is a palindrome (structures have the same size);
- Tip: if at least one of the pairs of characters is not equal, so the word is not a palindrome.