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

Minimum Appends for Palindrome!


Problem Description

Given a string A consisting of lowercase characters.

We need to tell minimum characters to be appended (insertion at end) to make the string A a palindrome.



Problem Constraints

1 <= |A| <= 105

A consists only of lower-case characters.



Input Format

First argument is an string A.



Output Format

Return a integer denoting the minimum characters to be appended (insertion at end) to make the string A a palindrome.



Example Input

Input 1:

 A = "abede"

Input 2:

 A = "aabb"



Example Output

Output 1:

 2

Output 2:

 2



Example Explanation

Explanation 1:

 We can make string palindrome as "abedeba" by adding ba at the end of the string.

Explanation 2:

 We can make string palindrome as "aabbaa" by adding aa at the end of the string.



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 Minimum Appends for Palindrome! on Interview Code Editor
Sign Up
to access hints and editorial solutions for Minimum Appends for Palindrome!
Asked In:

Discussion


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