package com.fishercoder.solutions;

import java.util.Arrays;

public class _645 {
    public static class Solution1 {
        public int[] findErrorNums(int[] nums) {
            int[] result = new int[2];
            Arrays.sort(nums);
            for (int i = 0; i < nums.length - 1; i++) {
                if (nums[i + 1] == nums[i]) {
                    result[0] = nums[i];
                }
            }
            long temp = 0;
            for (int i = 0; i < nums.length; i++) {
                temp += i + 1;
                temp -= nums[i];
            }
            temp += result[0];
            result[1] = (int) temp;
            return result;
        }
    }
}

@@ -53,16 +53,64 @@
 .Arrays;
+%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0Apublic
@@ -719,11 +719,656 @@
  %7D%0A    %7D
+%0A%0A    public static class Solution2 %7B%0A        public int%5B%5D findErrorNums(int%5B%5D nums) %7B%0A            Set%3CInteger%3E set = new HashSet();%0A            boolean%5B%5D has = new boolean%5Bnums.length%5D;%0A            int dup = -1;%0A            for (int i = 0; i %3C nums.length; i++) %7B%0A                has%5Bnums%5Bi%5D - 1%5D = true;%0A                if (!set.add(nums%5Bi%5D)) %7B%0A                    dup = nums%5Bi%5D;%0A                %7D%0A            %7D%0A            int dup2 = -1;%0A            for (int i = 0; i %3C has.length; i++) %7B%0A                if (!has%5Bi%5D) %7B%0A                    dup2 = i + 1;%0A                %7D%0A            %7D%0A            return new int%5B%5D%7Bdup, dup2%7D;%0A        %7D%0A    %7D
 %0A%7D%0A

refactor 645