```
public class Solution {
public int[] findErrorNums(int[] nums) {
int[] res = new int[2];
int[] mark = new int[nums.length+1];
for(int num:nums) mark[num]++;
for(int i=1; i<mark.length; i++){
if(mark[i] == 2) res[0] = i;
if(mark[i] == 0) res[1] = i;
}
return res;
}
}
```