448. Find All Numbers Disappeared in an Array

448. Find All Numbers Disappeared in an Array

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s