Python easy peasy bottom up DP
Here dp[i] means, minimum no. of swaps to make A[:i+1] and B[:i+1] increasing.\ndp[i][0] means, when ith index is not swapped.\ndp[i][1] means, when ith index i
Here dp[i] means, minimum no. of swaps to make A[:i+1] and B[:i+1] increasing.\ndp[i][0] means, when ith index is not swapped.\ndp[i][1] means, when ith index is swapped.\n\n```\ndef usingDP(self, A, B):\n        dp = [[float(\'inf\'), float(\'inf\')] for i in range(len(A))]     #[NotSwapped, Swapped]\n        \n        dp[0][0] = 0\n        dp[0][1] = 1\n        \n        for i in range(1, len(dp)):\n            if A[i]>A[i-1] and B[i]>B[i-1]:\n                dp[i][0] = min(dp[i][0], dp[i-1][0])\n            \n            if A[i]>B[i-1] and B[i]>A[i-1]:\n                dp[i][0] = min(dp[i][0], dp[i-1][1])\n            \n            if B[i]>A[i-1] and A[i]>B[i-1]:\n                dp[i][1] = min(dp[i][1], dp[i-1][0]+1)\n            \n            if B[i]>B[i-1] and A[i]>A[i-1]:\n                dp[i][1] = min(dp[i][1], dp[i-1][1]+1)\n        \n        return min(dp[-1])\n```\n\n
['Dynamic Programming', 'Python3']