**害,这个题白忙活半天。人家是想要输出原字符串中最靠前的字母,我以为是ACSLL表中最靠前的字母,就用双指针写
结果就一直WA。搞得我蛮无解的,后来又看了一下题目,发现自己把题目误判了......****
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
string s;
cin >> s;
vector<char>a;
int n = s.size();
sort(s.begin(), s.end());
int i = 0;
int j = i;
while (i <= n)
{
j++;
if (s[i] == s[j])
{
while (j <= n - 1 && s[i] == s[j])
{
j++;
}
i = j;
}
else
{
a.push_back(s[i]);
i++;
}
}
int m = a.size();
if(m==0)
{
cout<<"no";
}else{
cout << a[m - 1];
}
return 0;
}