C++ || Easy & Simple Code || DP
\nclass Solution {\npublic:\n    int minSwap(vector<int>& A, vector<int>& B) {\n        int swaps = 0,up = 0, down = 0;\n        for (int i = 0; i < A.size(); +
```\nclass Solution {\npublic:\n    int minSwap(vector<int>& A, vector<int>& B) {\n        int swaps = 0,up = 0, down = 0;\n        for (int i = 0; i < A.size(); ++i) {\n            if (A[i] > B[i]){up += 1;}\n            else{down += 1;}\n\n            if (i == A.size() - 1 || max(A[i], B[i]) < min(A[i + 1], B[i + 1])) {\n                swaps += min(up, down);\n                up = down = 0;\n            }\n        }\n        return swaps;\n    }\n};\n```\nDo upvote if it helped :)
['Dynamic Programming', 'C']