vector<int> findErrorNums(vector<int>& nums) { const int N = 10001; int S[N]; int n = nums.size(); for (int i = 0; i < N; i++) { S[i] = 0; } for (int i = 1; i <= n; i++) { int m = nums[i - 1]; S[m]++; } int dup = -1; int miss = -1; for (int i = 1; i <= n; i++) { if (S[i] == 2 && dup == -1) { dup = i; } if (S[i] == 0 && miss == -1) { miss = i; } } vector<int> R; R.push_back(dup); R.push_back(miss); return R; }