My solution beat 91%, need extra space


  • 0
    Y

    public class Solution {

        public List<Integer> findDisappearedNumbers(int[] nums) {
    
        int[] temp = new int[nums.length];
    
        List<Integer> result = new ArrayList<>();
        
        for(int t : nums){
            temp[t-1] = 1;
        }
        for(int i = 0; i < temp.length; i++){
            if(temp[i] == 0)    result.add(i+1);
        }
        
        return result;
    }
    

    }


Log in to reply
 

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