Question: Given a string s we need to tell minimum characters to be appended (insertion at the end) to make a string palindrome. Examples: Input :

Given a string s we need to tell minimum characters to be appended (insertion at the end) to make a string palindrome.

Examples:

Input : s = "abede" Output : 2 We can make string palindrome as "abedeba" by adding ba at the end of the string. Input : s = "aabb" Output : 2 We can make string palindrome as"aabbaa" by adding aa at the end of the string.Recommended: Please try your approach on {IDE} first, before moving on to the solution.

The solution can be achieved by removing characters from the beginning of the string one by one and checking if the string is palindrome or not. For Example, consider the above string, s = abede. We check if the string is palindrome or not. The result is false, then we remove the character from the beginning of a string and now string becomes bede. We check if the string is palindrome or not. The result is again false, then we remove the character from the beginning of a string and now the string becomes ede. We check if the string is palindrome or not. The result is true, so the output becomes 2 which is the number of characters removed from the string.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!