Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication66;
  7.  
  8. import java.util.ArrayList;
  9. import java.util.HashSet;
  10. import java.util.List;
  11.  
  12. /**
  13.  *
  14.  * @author Usuario
  15.  */
  16. public class JavaApplication66 {
  17.  
  18.     public List<Integer> findDisappearedNumbers(int[] nums) {
  19.         // write your code here
  20.        
  21.         HashSet<Integer> hash =
  22.                 new HashSet();
  23.        
  24.         //int min = Integer.MAX_VALUE;
  25.         //int max = Integer.MIN_VALUE;
  26.         for(int i =0; i<nums.length; i++) {
  27.             hash.add(nums[i]);
  28.            // min = Math.min(min, nums[i]);
  29.             //max = Math.max(max, nums[i]);
  30.         }
  31.        
  32.         ArrayList<Integer> lista =
  33.                 new ArrayList();
  34.        
  35.        
  36.         for(int i = 1; i <= nums.length; i++) {
  37.             if(!hash.contains(i)) {
  38.                 lista.add(i);
  39.             }
  40.             hash.add(i);
  41.         }
  42.        
  43.         return lista;
  44.        
  45.     }
  46.     public static void main(String[] args) {
  47.         // TODO code application logic here
  48.     }
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement