K-Substring with K different characters(sliding window)
Description
Given a string S and an integer K. Calculate the number of substrings of length K and containing K different characters
Have you met this question in a real interview?
Yes
Problem Correction
Example
分析
for 里面I做end指针,直接用i-k,不用start指针了。
几大元素:start, end, map, count, size of substring(maybe)
这里count检测map进入1和退出0的情况,然后++ --
这里需要set 为了去重 比如重复出现的ab
Last updated