Python DP solution O(n) Time and O(1) Space
\nclass Solution:\n    def minSwap(self, nums1: List[int], nums2: List[int]) -> int:\n        dp_none_swapped = 0\n        dp_swapped = 1\n        n = len(nums1
```\nclass Solution:\n    def minSwap(self, nums1: List[int], nums2: List[int]) -> int:\n        dp_none_swapped = 0\n        dp_swapped = 1\n        n = len(nums1)\n        for i in range(1, n):\n            #First, if at i, we don\'t swap\n            #Then, if at i, we swap   \n            new_none_swapped = n + n\n            new_swapped = n + n\n            if nums1[i] > nums1[i-1] and nums2[i] > nums2[i-1]:\n                new_none_swapped = min(new_none_swapped, dp_none_swapped)\n                new_swapped = min(dp_swapped + 1, new_swapped)\n            if nums1[i] > nums2[i-1] and nums2[i] > nums1[i-1]:\n                new_none_swapped = min(dp_swapped, new_none_swapped)\n                new_swapped = min(dp_none_swapped + 1, new_swapped)\n             \n            dp_none_swapped = new_none_swapped\n            dp_swapped = new_swapped\n            \n        return min(dp_none_swapped, dp_swapped)\n```
[]