class Solution {
public List<Integer> findAnagrams(String s, String p) {
List<Integer> res = new ArrayList<>();
int[] map = new int[256];
if (s.length() == 0 || s == null || p.length()==0 || p == null){
return res;
}
//记录一下p中char的个数
for (char cur : p.toCharArray()){
map[cur]++;
}
int left = 0;
int right = 0;
int count = p.length();
while(right < s.length()){
//判断当前right位置的char是否大于0
if (map[s.charAt(right)] > 0){
count--;
}
map[s.charAt(right)]--;
right++;
if(count == 0){
res.add(left);
}
if(right - left == p.length()){
if (map[s.charAt(left)] >= 0){
count++;
}
map[s.charAt(left)]++;
left++;
}
}
return res;
}
}