Recursive with memoization (beats 100.00 %):
\nclass Solution {    \n\n    int[][] dp;\n    \n    public int minSwap(int[] A, int[] B) {\n        dp = new int[A.length][2];\n        for (int[] row: dp)\n  
```\nclass Solution {    \n\n    int[][] dp;\n    \n    public int minSwap(int[] A, int[] B) {\n        dp = new int[A.length][2];\n        for (int[] row: dp)\n            Arrays.fill(row, -1);\n        return minSwapHelper(A, B, 0, -1, -1, 0);\n    }\n    \n    private int minSwapHelper(int[] A, int[] B, int i, int prevA, int prevB, int swapped) {\n        if(i == A.length) return 0;\n    \tif(dp[i][swapped] != -1) return dp[i][swapped];\n        int minSwaps = Integer.MAX_VALUE;\n        if(A[i] > prevA && B[i] > prevB) {\n            minSwaps = minSwapHelper(A, B, i + 1, A[i], B[i], 0);\n        }\n        swap(A, B, i);\n        if(A[i] > prevA && B[i] > prevB) {\n            minSwaps = Math.min(minSwaps, minSwapHelper(A, B, i + 1, A[i], B[i], 1) + 1);\n        }\n        swap(A, B, i);\n        dp[i][swapped] = minSwaps;\n        return minSwaps;\n    }\n    \n    private void swap(int[] A, int[] B, int i) {\n        int t = A[i];\n        A[i] = B[i];\n        B[i] = t;\n    }\n}\n```\n\n##### Minor improvements (no swap call)\n\n```\nclass Solution {\n    \n    Integer[][] dp;\n    final int MAX  = 10_000;\n    \n    public int minSwap(int[] A, int[] B) {\n        dp = new Integer[A.length][2];            \n        return minSwapHelper(A, B, 0, -1, -1, 0);\n    }\n    \n    private int minSwapHelper(int[] A, int[] B, int i, int prevA, int prevB, int swapped) {\n        \n        if(i == A.length) return 0;\n    \tif(dp[i][swapped] != null) return dp[i][swapped];\n        \n        int minSwaps = MAX;\n        \n        if(A[i] > prevA && B[i] > prevB) { // with-no-swap\n            minSwaps = minSwapHelper(A, B, i + 1, A[i], B[i], 0);\n        }\n        \n        if(B[i] > prevA && A[i] > prevB) { // with-swap\n            minSwaps = Math.min(minSwaps, minSwapHelper(A, B, i + 1, B[i], A[i], 1) + 1);\n        }\n\n        dp[i][swapped] = minSwaps;\n        return minSwaps;\n    }\n    \n}\n```
[]