Simple java solution


  • 0
    A
        public List<Integer> findDisappearedNumbers(int[] nums) {
            int[] n=new int[nums.length+1];
            ArrayList<Integer> ans=new ArrayList<Integer>();
            for(int i=0;i<nums.length;i++)n[nums[i]]=nums[i];
            for(int i=1;i<n.length;i++){
              if(i-n[i]!=0)
              ans.add(i);
            }
            return ans;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.