Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication66;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.List;
- /**
- *
- * @author Usuario
- */
- public class JavaApplication66 {
- public List<Integer> findDisappearedNumbers(int[] nums) {
- // write your code here
- HashSet<Integer> hash =
- new HashSet();
- //int min = Integer.MAX_VALUE;
- //int max = Integer.MIN_VALUE;
- for(int i =0; i<nums.length; i++) {
- hash.add(nums[i]);
- // min = Math.min(min, nums[i]);
- //max = Math.max(max, nums[i]);
- }
- ArrayList<Integer> lista =
- new ArrayList();
- for(int i = 1; i <= nums.length; i++) {
- if(!hash.contains(i)) {
- lista.add(i);
- }
- hash.add(i);
- }
- return lista;
- }
- public static void main(String[] args) {
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement