Java solution


  • 0
    R
    public static List findDisappearedNumbers(int[] nums) {
    		Set s = new HashSet();
    		for(int i = 1; i <=nums.length; i++) {
    			s.add(i);
    		}
    		
    		for(int n : nums) {
    			if(s.contains(n)) {
    				s.remove(n);
    			}
    		}
    		
    		List list = new ArrayList<>(s);
    		return list;
    	}

Log in to reply
 

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