美文网首页
CodeFoeces-864B

CodeFoeces-864B

作者: ss5smi | 来源:发表于2018-03-01 15:36 被阅读0次

题目

原题链接: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;
}

相关文章

  • CodeFoeces-864B

    题目 原题链接:B. Polycarp and Letters 题意 在所给的字符串中找只有小写字母的子串的最大不...

网友评论

      本文标题:CodeFoeces-864B

      本文链接:https://www.haomeiwen.com/subject/dsbgxftx.html