#C7660. Longest Even Occurrences Substring
Longest Even Occurrences Substring
Longest Even Occurrences Substring
Problem Description:
You are given a string ( S ) consisting of lowercase English letters. Your task is to determine the length of the longest substring of ( S ) in which every character appears an even number of times. Formally, for any substring ( S[i \ldots j] ), the condition is that for every character ( c ), the frequency ( f_{c} ) in the substring is even (i.e., ( f_{c} \equiv 0 \pmod{2} )).
For example, given the input "abba", the entire string is a valid substring since both 'a' and 'b' appear twice, resulting in a length of 4.
inputFormat
Input is read from standard input. It consists of a single line containing the string ( S ) (consisting only of lowercase English letters).
outputFormat
Output the length (an integer) of the longest substring where every character appears an even number of times. The result should be printed to standard output.## sample
abba
4