CodeFoeces-864B

2018-03-01  本文已影响0人  ss5smi

题目

原题链接:B. Polycarp and Letters

题意

在所给的字符串中找只有小写字母的子串的最大不同字母个数。
参考了其他作者的题意解读。

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
    int l;
    string s;
    set<char> st;
    cin>>l>>s;
    int ans=0;
    for(int i=0; i<l; i++) {
        if(s[i]>='a' && s[i]<='z') {
            st.insert(s[i]);
        } else {
            ans=max(ans,(int)st.size());
            st.clear();
        }
    }
    ans=max(ans,(int)st.size());
    cout<<ans<<endl;
    return 0;
}
上一篇 下一篇

猜你喜欢

热点阅读