RECUR11 Editorial

Problem Explanation

You are given a string and you have to tell if it is a Palindrome. Palindromes are strings that are the same when reversed.


Palindromes are mirrored in the middle. So we can check if the 0^{th} index character is the same as the (n-1)^{th} character, the 1^{st} character is the same as the (n-2)^{th} character and so on untill the middle which is n/2. So we iterate from the beginning of the string till the middle and check for every i, the i^{th} character is equal to the (n-i-1)^{th} character or not. If not then we output that it is not a palindrome and if the whole string is iterated then it is a Palindrome.


def check_palindrome(s, n):
        return "Yes"
        return "No"
    return check_palindrome(s, n+1)
1 Like

first fall it used to python programming language than question is that check the palindrome number so it is used in function than two input s and n than condition n is greater than length (s) /2 than condition is true so return yes but this condition is not true than second condition s[n] is not equal to s{length(s)-n-1]) then return no and than return function of (s, n+1)