Beats 99.29% Python
\n    def minSwap(self, A, B):\n        n = len(A)\n        prevNotSwap = 0\n        prevSwap = 1\n        for i in range(1, n):\n            areBothSelfIncreas
```\n    def minSwap(self, A, B):\n        n = len(A)\n        prevNotSwap = 0\n        prevSwap = 1\n        for i in range(1, n):\n            areBothSelfIncreasing = A[i - 1] < A[i] and B[i - 1] < B[i] \n            areInterchangeIncreasing = A[i - 1] < B[i] and B[i - 1] < A[i]\n            if areBothSelfIncreasing and areInterchangeIncreasing:\n                newPrevNotSwap = min(prevNotSwap, prevSwap)\n                prevSwap = min(prevNotSwap, prevSwap) + 1\n                prevNotSwap = newPrevNotSwap\n            elif areBothSelfIncreasing:\n                prevSwap += 1 \n            else: # if areInterchangeIncreasing:\n                newPrevNotSwap = prevSwap\n                prevSwap = prevNotSwap + 1\n                prevNotSwap = newPrevNotSwap\n        return min(prevNotSwap, prevSwap)\n```\n**(\u4EBA \u2022\u0348\u1D17\u2022\u0348)** Thanks for voting!
[]