package leetcode;

/**
 * https://leetcode.com/problems/fair-candy-swap/
 */
public class Problem888 {
    public int[] fairCandySwap(int[] A, int[] B) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem888 prob = new Problem888();
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -185,132 +185,1067 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem888 prob = new Problem888();
+int sumA = 0;%0A        for (int a : A) %7B%0A            sumA += a;%0A        %7D%0A        int sumB = 0;%0A        for (int b : B) %7B%0A            sumB += b;%0A        %7D%0A        int%5B%5D result = new int%5B2%5D;%0A        outer:%0A        for (int a : A) %7B%0A            for (int b : B) %7B%0A                if (sumA - a + b == sumB - b + a) %7B%0A                    result%5B0%5D = a;%0A                    result%5B1%5D = b;%0A                    break outer;%0A                %7D%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem888 prob = new Problem888();%0A        System.out.println(Arrays.toString(prob.fairCandySwap(%0A            new int%5B%5D%7B1, 1%7D, new int%5B%5D%7B2, 2%7D))); // %5B1,2%5D%0A        System.out.println(Arrays.toString(prob.fairCandySwap(%0A            new int%5B%5D%7B1, 2%7D, new int%5B%5D%7B2, 3%7D))); // %5B1,2%5D%0A        System.out.println(Arrays.toString(prob.fairCandySwap(%0A            new int%5B%5D%7B2%7D, new int%5B%5D%7B1, 3%7D))); // %5B2,3%5D%0A        System.out.println(Arrays.toString(prob.fairCandySwap(%0A            new int%5B%5D%7B1, 2, 5%7D, new int%5B%5D%7B2, 4%7D))); // %5B5,4%5D
 %0A   

Update problem 888