InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Convert to Palindrome


Problem Description

Given a string A consisting only of lowercase characters, we need to check whether it is possible to make this string a palindrome after removing exactly one character from this.

If it is possible then return 1 else return 0.



Problem Constraints

3 <= |A| <= 105

A[i] is always a lowercase character.



Input Format

First and only argument is an string A.



Output Format

Return 1 if it is possible to convert A to palindrome by removing exactly one character else return 0.



Example Input

Input 1:

 A = "abcba"

Input 2:

 A = "abecbea"



Example Output

Output 1:

 1

Output 2:

 0



Example Explanation

Explanation 1:

 We can remove character ‘c’ to make string palindrome

Explanation 2:

 It is not possible to make this string palindrome just by removing one character 



NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Convert to Palindrome on Interview Code Editor
Sign Up
to access hints and editorial solutions for Convert to Palindrome
Asked In:

Discussion


Loading...
Click here to start solving coding interview questions