Sometimes it’s easier to solve a problem if you use a mix of data structures. For example, you can easily determine whether a sequence of characters is a palindrome if you use both a stack and a queue. Just add the characters of the sequence to each data structure, and then remove a character from each data structure one at a time and compare them. The sequence is a palindrome if and only if the characters are always the same.

Here is my C++ implementation of a palindrome checker.

Here is a Python implementation of a palindrome checker.

Both implementations are up at my GitHub.

### Like this:

Like Loading...

*Related*