美文网首页
395. Longest Substring with At L

395. Longest Substring with At L

作者: 我是你的果果呀 | 来源:发表于2016-12-26 05:55 被阅读0次

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 L

      本文链接:https://www.haomeiwen.com/subject/qoodvttx.html