#K79947. Longest Even Frequency Substring
Longest Even Frequency Substring
Longest Even Frequency Substring
You are given a string (s) consisting of lowercase English letters. Your task is to find the length of the longest contiguous substring in which every distinct character appears an even number of times. In other words, for a substring (s[i \ldots j]), if the frequency of every character in that substring is even (i.e. divisible by 2), then the substring is considered valid. If no such substring exists, output (0).
For example, when (s = \texttt{abccba}), every character in the entire string appears an even number of times, hence the answer is (6).
inputFormat
Input is given as a single line from standard input containing a non-empty string of lowercase English letters.
outputFormat
Output a single integer representing the length of the longest substring in which every character appears an even number of times.## sample
abccba
6
</p>