DeloitteOA #6
Longest Substring with Even Occurrences
Estimated MediumJudge-ready
Topics (AI-labelled)Prefix & RangesBits & MathHashing
Find the longest contiguous substring in which every English letter occurs an even number of times; if no non-empty substring exists, output 0.
This site's standard input/output format and any supplementary ranges follow this problem's description.
Input
One line containing a string of only lowercase English letters, 1≤|S|≤100000.
Output
Output the longest length.
Example 1
Input:
bdaaadadb
Output:
6
Example 2
Input:
abacb
Output:
0
Example 3
Input:
zthtzh
Output:
6
Editorial
Loading solution…