Given a string of characters, Check if the given string is a palindrome or not. A palindrome is a word, phrase, or sequence that reads the same backward as forwards, e.g. "racecar" or nurses run.
Input: "manuunam";
Output: true;
The string manuunam
, if reversed, is the same. Hence, it is a palindrome.
Input: "race car";
Output: false;
Since there is a space, we are going to count it in our computations. Hence, the reversed string will be rac ecar
, which is not equal to race car
.
Input: "algochurn practice";
Output: false;
The string algochurn practice
, if reversed, is not the same as algochurn practice
. Hence, it is not a palindrome.
Click to reveal
Can you use javascript's native method to solve this problem? reverse()
might be a good choice.
Click to reveal
Can you try solving this problem recursively? passing the index every time you recurse?
Click to reveal
Do you need to iterate the entire array to check if a string is a palindrome or not?