3 条题解
-
0
//最简单的方法 #include <bits/stdc++.h> using namespace std; int l,r,cnt[1001]; string s; int main() { // freopen("filename.in", "r", stdin); // freopen("filename.out", "w", stdout); cin>>s; l=1,r=1; int ans=0; for(;r<=s.size();r++) { cnt[s[r-1]-'a']++; while(cnt[s[r-1]-'a']>1)cnt[s[l-1]-'a']--,l++; ans=max(ans,r-l+1); } cout<<ans; return 0; }
- 1
信息
- ID
- 632
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- (无)
- 递交数
- 157
- 已通过
- 76
- 上传者