题解 | #提取不重复的整数#

提取不重复的整数

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};

全部评论

相关推荐

06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务