package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/set-mismatch/
 */
public class Problem645 {
    public int[] findErrorNums(int[] nums) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem645 prob = new Problem645();
        System.out.println(Arrays.toString(prob.findErrorNums(new int[]{1, 2, 2, 4}))); // [2, 3]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -150,230 +150,444 @@
     
-// TODO%0A        return null
+int duplicate = 0;%0A        boolean%5B%5D b = new boolean%5Bnums.length%5D
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem645 prob = new Problem645();%0A        System.out.println(Arrays.toString(prob.findErrorNums(new int%5B%5D%7B1, 2, 2, 4%7D))); // %5B2, 3%5D
+for (int num : nums) %7B%0A            if (b%5Bnum - 1%5D) %7B%0A                duplicate = num;%0A            %7D%0A            b%5Bnum - 1%5D = true;%0A        %7D%0A        int missing = 0;%0A        for (int i = 0; i %3C b.length; i++) %7B%0A            if (!b%5Bi%5D) %7B%0A                missing = i + 1;%0A                break;%0A            %7D%0A        %7D%0A        return new int%5B%5D%7Bduplicate, missing%7D;
 %0A   

Solve problem 645