题解 | 提取不重复的整数
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
#include <bits/stdtr1c++.h> // 万能头
using namespace std;
int main() {
string s;
cin>>s;// 输入
set<char>se; // 需要用set来去重
for(int i=s.size()-1;i>=0;i--){ // 从后面开始遍历
if(se.count(s[i])==0){ // 判断是否存在
cout<<s[i];
se.insert(s[i]);// 没有的话就插入进去
}
}
}
// 64 位输出请用 printf("%lld")
牛客春招刷题训练营 https://www.nowcoder.com/discuss/727521113110073344
#牛客创作赏金赛#
查看11道真题和解析