1 条题解

  • 0
    @ 2025-8-19 18:24:24

    O(N)O(N)

    按照小写字母、数字、大写字母的顺序将三类字符从前向后输出。

    #include<bits/stdc++.h>
    
    using namespace std;
    
    typedef long long LL;
    typedef pair<LL, LL> PII;
    
    #define x first
    #define y second
    
    const int N = 2e5 + 10, M = 30;
    
    int a[N];
    
    void solve() 
    {
        int n;
        string s;
        cin >> n >> s;
        for(int i = 0; i < n; i ++)
            if(s[i] >= 'a' && s[i] <= 'z')
                cout << s[i];
        for(int i = 0; i < n; i ++)
            if(s[i] >= '0' && s[i] <= '9')
                cout << s[i];
        for(int i = 0; i < n; i ++)
            if(s[i] >= 'A' && s[i] <= 'Z')
                cout << s[i];
    }            
    
    int main()
    {
        int t = 1;
        // cin >> t;
        while(t --)
            solve();
    }
    
    • 1

    信息

    ID
    536
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    5
    已通过
    2
    上传者