CodeFights – CheckPalindrome


Given the string, check if it is a palindrome.

Example

  • For inputString = "aabaa", the output should be
    checkPalindrome(inputString) = true;
  • For inputString = "abac", the output should be
    checkPalindrome(inputString) = false;
  • For inputString = "a", the output should be
    checkPalindrome(inputString) = true.

Walk Through

There are several ways to check check if a string is a palindrome. In this solution, the string is compared to a string that has reversed. The string is reversed by using the following methods.

  • String.split() to create a character array.
  • Array.reverse() to reverse the array
  • Array.join() to create a new string

Links

Leave a Reply

Your email address will not be published. Required fields are marked *