Mark As Completed Discussion

Let's see how we will implement it through code. At first, we will check if our string is of length 1 or not. If it has a length of 1, then we don't have to proceed, as you know that a single character is a palindrome by itself.

Implementation

Then we can check if our string is of length 2 or not. We are checking these specific lengths to avoid extra work, as our function doesn't have to execute all the awy. Adding these checks will improve the method's performance.

Implementation

What will happen if we pass the string "Maham"?