package leetcode;

/**
 * https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/
 */
public class Problem801 {
    public int minSwap(int[] A, int[] B) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem801 prob = new Problem801();
        System.out.println(prob.minSwap(new int[]{1, 3, 5, 4}, new int[]{1, 2, 3, 7})); // 1
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -204,32 +204,1116 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        int i = 0;%0A        int j = 0;%0A        while (i %3C A.length && j %3C B.length) %7B%0A            while (i + 1 %3C A.length && A%5Bi%5D %3C A%5Bi + 1%5D) %7B%0A                i++;%0A            %7D%0A            while (j + 1 %3C B.length && B%5Bj%5D %3C B%5Bj + 1%5D) %7B%0A                j++;%0A            %7D%0A            boolean swap = (i + 1 %3C A.length && A%5Bi%5D %3E= A%5Bi + 1%5D) %7C%7C%0A                (j + 1 %3C B.length && B%5Bj%5D %3E= B%5Bj + 1%5D);%0A            if (swap) %7B%0A                if (i %3C j) %7B%0A                    swap(A, B, i + 1);%0A                    j = i;%0A                    answer++;%0A                %7D else if (i %3E j) %7B%0A                    swap(A, B, j + 1);%0A                    i = j;%0A                    answer++;%0A                %7D else %7B%0A                    swap(A, B, i + 1);%0A                    answer++;%0A                %7D%0A            %7D%0A            i++;%0A            j++;%0A        %7D%0A        System.out.println(Arrays.toString(A));%0A        System.out.println(Arrays.toString(B));%0A        return answer;%0A    %7D%0A%0A    private static void swap(int%5B%5D a, int%5B%5D b, int i) %7B%0A        int tmp = a%5Bi%5D;%0A        a%5Bi%5D = b%5Bi%5D;%0A        b%5Bi%5D = tmp
 ;%0A  
@@ -1406,16 +1406,18 @@
 m801();%0A
+//
         
@@ -1501,16 +1501,217 @@
 ); // 1%0A
+//        System.out.println(prob.minSwap(new int%5B%5D%7B1, 3, 5, 4, 8%7D, new int%5B%5D%7B1, 2, 3, 7, 5%7D)); // 1%0A        System.out.println(prob.minSwap(new int%5B%5D%7B0, 4, 4, 5, 9%7D, new int%5B%5D%7B0, 1, 6, 8, 10%7D)); // 1%0A
     %7D%0A%7D%0A

Update problem 801