Posted on

Description

Submission

class Solution {
public:
    int findRepeatNumber(vector<int>& nums) {
        vector<int> counter(nums.size());
        for(int i = 0; i < nums.size(); ++i) {
            counter[nums[i]]++;
            if(counter[nums[i]] > 1) return nums[i];
        }
        return nums.back();
    }
};

Leave a Reply

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