12 条题解

  • 0
    @ 2023-4-19 18:55:26

    由于z的ASCII码为122,所以数组开到123就行了,如果想要更小一点,就把a[i]换成a[i]-'a',数组就可以开到26。

    #include<iostream>
    #include<iomanip>
    #include<stdio.h>
    #include<math.h>
    #include<string>
    #include<string.h>
    #include<sstream>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    const int N=1e5+1;
    const int INF=0x3f3f3f3f;
    string a;
    int x[123];
    int main(){
    	cin>>a;
    	int s=a.size();
    	for(int i=0;i<s;i++)x[a[i]]++;
    	for(int i=0;i<s;i++)
    		if(x[a[i]]==1){
    			cout<<a[i];
    			return 0;
    		}
    	cout<<"no";
    	return 0;
    }
    

    信息

    ID
    1153
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    递交数
    653
    已通过
    222
    上传者