image_2021-11-18_14-37-00.png
38.3 KB
#N448. Find All Numbers Disappeared in an Array
problem link
#solution
problem link
#solution
class Solution {
public List<Integer> findDisappearedNumbers(int[] nums) {
List<Integer> res=new ArrayList<>();
int[] count=new int[nums.length+1];
for(int num:nums)
count[num]++;
for(int i=1; i<count.length; i++){
if(count[i]==0)
res.add(i);
}
return res;
}
}