← 返回 meta 的题目列表Shortest Distinct Substring (N=3 variant)
类型:online_judge
Problem: Shortest Distinct Substring (N=3 variant)
You are given a lowercase string s and an integer N = 3.
A substring is considered distinct if all characters inside it are pairwise different.
Find the shortest distinct substring in s.
If multiple substrings have the same shortest length, return the leftmost one.
If no distinct substring exists, return an empty string.
Note: Since N=3 is given, the answer length will be at most 3. If a length-1 or length-2 substring is already distinct, you should return the shorter one.
Input (stdin)
One line: string s
Output (stdout)
One string: the shortest distinct substring (or empty string)
Constraints
1 <= len(s) <= 2 * 10^5
s consists of a-z
Examples / Tests
Test 1
aab
Output
ab
Test 2
aaa
Output
Test 3
abc
Output
a
Test 4
abba
Output
ab
Test 5
zzxyzz
Output
z
Example
Input
aab
Output
""