Back
Close
  • 59

Statement

 Goal

Given a string S of length N find the minimum number of characters that you need to add to the end in order to make S a palindrome.
Example:
N=4 and S='ABCB' we can add 'A' to the end of S making it a valid palindrome (ABCBA). Thus, the answer is 1.
Input
Line 1: N an integer denoting the length of the string.
Line 2: S the string.
Output
An integer denoting the minimum number of charcters to add at the end to transform the string into a palindrome
Constraints
1<N<10000
S contains only uppercase characters.
Example
Input
4
ABCB
Output
1

A higher resolution is required to access the IDE