395. Longest Substring with At Least K Repeating Characters

Find the length of the longest substringTof a given string (consists of lowercase letters only) such that every character inTappears no less thanktimes.

Example 1: Input:  = "aaabb", k = 3 Output: 3
The longest substring is "aaa", as 'a' is repeated 3 times.

Example 2: Input: s = "ababbc", k = 2 Output: 5
The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times.

devide and conquer 虽然也是使用递归, 但是是二分式递归, 速度要快很多. 将字符串出现次数放到26个字符数组中, 查找个数小于k的, 分别算左边和右边的最大值, 

395. Longest Substring with At Least K Repeating Characters_第1张图片

你可能感兴趣的:(395. Longest Substring with At Least K Repeating Characters)