题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
#include <algorithm> #include <iostream> #include <string> #include <unordered_map> #include <vector> using namespace std; int main() { long a; cin >> a; string str = to_string(a); reverse(str.begin(),str.end()); unordered_map<char,int>map; vector<int> array; for(char &c : str){ if(map.count(c) == 0){ map[c]++; array.push_back(c-'0'); } } //reverse(array.begin(),array.end()); for(int num : array){ cout << num ; } return 0; } // 64 位输出请用 printf("%lld")
根据前面出现过的题目,模仿出来的