Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-18_14-37-00.png
38.3 KB
#N448. Find All Numbers Disappeared in an Array
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;
}
}