C++ program without DP int time complexity of O(n) and space complexity O(1)
\nclass Solution {\npublic:\n    int minSwap(vector<int>& A, vector<int>& B) {\n        int c=0,k=1,temp;\n        for(int i=1;i<A.size();i++){\n            if 
```\nclass Solution {\npublic:\n    int minSwap(vector<int>& A, vector<int>& B) {\n        int c=0,k=1,temp;\n        for(int i=1;i<A.size();i++){\n            if (min(A[i],B[i])>max(A[i-1],B[i-1]))\n            {   c=min(c,k);\n                k=min(c,k)+1; \n            }\n        else if (A[i] > A[i-1] and B[i] > B[i-1])\n            k=k+1;\n        else{\n            temp=c;\n            c=k;\n            k=temp+1;\n        }\n    }\n        return min(c,k);\n    }\n};\n```
['C']