class Solution {
public:
vector<int> findAnagrams(string s, string p) {
if(s.size()<p.size())return {};
int l=0,r=-1;
vector<int>ana;
vector<int>frep_s(26,0),frep_p(26,0);
for(int i=0;i<p.size();i++){
frep_p[p[i]-'a']++;
frep_s[s[++r]-'a']++;
}
if(frep_p==frep_s)ana.push_back(l);
while(r<s.size()-1){
frep_s[s[++r]-'a']++;
frep_s[s[l++]-'a']--;
if(frep_p==frep_s)ana.push_back(l);
}
return ana;
}
};
class Solution {
public:
int numSubarrayProductLessThanK(vector<int>& nums, int k) {
if(k<=1)return 0;
int l=0,r=0,product=1,sum=0;
while(r<nums.size()){
product*=nums[r];
while(product>=k){
product/=nums[l++];
}
sum+=(r-l+1);
r++;
}
return sum;
}
};
class Solution {
public:
int minSubArrayLen(int target, vector<int>& nums) {
int l=0,r=0,mins=100000,sum=0;
while(r<nums.size()){
sum+=nums[r];
while(sum>=target){
mins=min(mins,r-l+1);
sum-=nums[l++];
}
r++;
}
return mins==100000?0:mins;
}
};