LCC '18 Contest 1 S3 - Abelian
View as PDFAn abelian square is a string of even length where the first half of the string is an anagram of the second half of the string. Here are some examples:
hannahis an abelian square.reappearis an abelian square.racecaris NOT an abelian square as it has odd length.sootis NOT an abelian square, but the substringoois an abelian square.
Given a string, determine the length of the longest substring that is an abelian square.
Input Specification
The first line of input contains an integer
.
The next line contains a lower-case string of
characters.
Output Specification
The length of the longest substring that is an abelian square.
Sample Input 1
8
reappear
Sample Output 1
8
Sample Input 2
11
programming
Sample Output 2
2
Comments