Posted on

Description

Submission

class Solution {
    int bucket[10005];
public:
    vector<int> findErrorNums(vector<int>& nums) {
        vector<int> rets(2);

        for(auto x: nums) {
            bucket[x]++;
        }

        for(int i = 1; i <= nums.size(); ++i) {
            if(bucket[i] == 2) rets[0] = i;
            if(bucket[i] == 0) rets[1] = i;
        }

        return rets;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *