for(int i=0;i<n;i++)
for(int j=0;j<=i;j++)
if(check(j,i)){
res=max(res,i-j+1);
}
for(int i=0;i<n;i++)
{
while(j<=i&&check(j,i)) j++;
res = max(res,i-j+1);
}
原文:https://www.cnblogs.com/bingers/p/13223955.html