AmazonOA #155
Find the Longest Isolated Substring Length
估计困难可在线判题
Find the longest non-empty contiguous substring such that none of its characters appears outside the substring, and the substring cannot equal the whole original string; if there is none, return 0.
输入格式
One line with a lowercase string of length 1..100000.
输出格式
Output a single integer answer.
样例 1
输入:
abcba
输出:
3
样例 2
输入:
amazonservices
输出:
11
样例 3
输入:
aaaa
输出:
0
样例说明
Example 1: in bcb, neither b nor c appears outside, so it is a proper substring of length 3; the source's 0 has been corrected. Example 2: zonservices has length 11, and outside it there are only a, m, a, which share no characters with it. Example 3: unless it is the whole string, any a inside appears outside as well, so there is no valid non-empty proper substring and the answer is 0.