Question 1 Solution: Palindrome Word

A phrase is a palindrome if it reads the same forward and backward.

For example, the word "radar" is a palindrome since the spelling is the same if we flip the words forward to backward. The word "race" is not a palindrome since it spells "ecar" backwards, which is not the same as the original word.

Problem Satement

Write a function that checks whether a string is a palindrome or not. The function should take in a string as a parameter, and return

True
if it is a palindrome, or
False
otherwise.

Solution

Note that there are multiple ways to solve this problem, the method provided here is not the only solution.

We compare the first character with the last character, see if they are the same, and continue to compare the second character and second-to-last character. We repeat this process until we reach the middle of the string.