438. 找到字符串中所有字母异位词
This commit is contained in:
@@ -18,7 +18,7 @@ public:
|
|||||||
|
|
||||||
if(checkCnt(cnts, cntp)) { ret.push_back(0);}
|
if(checkCnt(cnts, cntp)) { ret.push_back(0);}
|
||||||
|
|
||||||
for(int r = p.length(); r < s.length(); r++){
|
for(int r = p.length(); r < s.length(); r++){ // sliding window
|
||||||
int l = r - p.length() + 1;
|
int l = r - p.length() + 1;
|
||||||
cnts[s[l-1] - 'a']--;
|
cnts[s[l-1] - 'a']--;
|
||||||
cnts[s[r] - 'a']++;
|
cnts[s[r] - 'a']++;
|
||||||
|
|||||||
Reference in New Issue
Block a user