Least Substring
Description
Given a string containingn
lowercase letters, the string needs to divide into several continuous substrings, the letter in the substring should be same, and the number of letters in the substring does not exceedk
, and output the minimal substring number meeting the requirement.
n \leq 1e5
n
≤
1
e
5
Have you met this question in a real interview?
Yes
Problem Correction
Example
Gives = "aabbbc", k = 2
, return4
Gives = "aabbbc", k = 3
, return3
分析
遇到cnt == k或者字母变化就res+=1 cnt = 0 否则cnt ++
不是很懂
Last updated
Was this helpful?