cswork / OA打开练习工作台

SnowflakeOA #35

Max Frequency Substring

估计中等可在线判题

考点(AI 标注)哈希计数双指针滑窗

Among contiguous substrings with length in [minLength,maxLength] and a number of distinct characters ≤maxUnique, find the maximum number of occurrences of the same text; overlapping occurrences are allowed. Return 0 if no substring qualifies.

输入格式

This site's JSON input: [s,minLength,maxLength,maxUnique], which may contain escaped whitespace or Unicode; lengths are counted in Unicode characters. This site uses 1≤|s|≤100000, 1≤minLength≤maxLength≤|s|, and 1≤maxUnique≤100000.

输出格式

Output the single integer required by the problem.

样例 1

输入:

["aaaa", 2, 3, 1]

输出:

3

样例 2

输入:

["aabcaab", 2, 4, 2]

输出:

2

样例 3

输入:

["a b a b", 3, 5, 3]

输出:

2

样例说明

The answers to the three public examples are, in order: 3; 2; 2. The examples were rechecked by independent enumeration, state search, or direct simulation.