Java solution


  • 0
    R
    public class Solution {
        public List<Integer> findDisappearedNumbers(int[] nums) {
            List<Integer> l = new ArrayList<Integer>();
    
            boolean[] tab = new boolean[nums.length];
    
            for (int i = 0; i < nums.length; i++){
                tab[nums[i] - 1] = true;
            }
    
            for (int i = 0; i < nums.length; i++){
                if (!tab[i]) {
                    l.add(i+1);
                }
            }
    
            return l;
        }
    }
    
    

Log in to reply
 

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