题解 | #提取不重复的整数#
提取不重复的整数
http://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
cin >> str;
int n = str.size();
int hash[10] = {0};
//vector<int> hash(10,0);
for(int i = n-1; i >= 0; i--){
if(hash[str[i]-'0'] == 0){
cout << str[i]-'0';
hash[str[i]-'0'] = 1;
}
}
}
哈希表初始化:
vector hash(10,0);
int hash[10] = {0};