SalesforceOA #22
Get Special Substring (MTS)
估计中等可在线判题
考点(AI 标注)双指针滑窗
The 26-character charValue corresponds to a..z in order, where 0 marks a normal character and 1 marks a special character. Find the length of the longest contiguous substring of s in which normal characters occur at most k times; repeated normal characters are counted by occurrences.
输入格式
The input has three lines: s, k, charValue. Original bounds: 1≤|s|≤100000, s consists of a..z, and charValue has length 26 and contains only 0/1; the original "length of k" is a typo for an integer parameter, so this site specifies 1≤k≤|s|.
输出格式
Output one integer answer.
样例 1
输入:
giraffe
2
01111001111111111011111111
输出:
3
样例 2
输入:
special
1
00000000000000000000000000
输出:
1
样例 3
输入:
abcde
1
10101111111111111111111111
输出:
3
样例说明
The outputs of the three public examples are, in order: 3; 1; 3. They have been checked by independent enumeration or direct simulation.