[C++] code like poetry | Top-down
\nclass Solution {\n    public:\n  \n    vector<vector<int>> memo;\n    \n    int f(vector<int> &A, vector<int> &B, int i, bool shouldSwap) {\n        int n = A
```\nclass Solution {\n    public:\n  \n    vector<vector<int>> memo;\n    \n    int f(vector<int> &A, vector<int> &B, int i, bool shouldSwap) {\n        int n = A.size();\n        if (i == n) return 0;\n        if (memo[shouldSwap][i] != -1) return memo[shouldSwap][i];\n        int a = A[i - 1], b = B[i - 1];\n        if (shouldSwap) swap(a, b);\n        int o1 = INT_MAX, o2 = INT_MAX;\n        if (B[i] > b && A[i] > a) o1 = f(A, B, i + 1, false);\n        if (A[i] > b && B[i] > a) o2 = 1 + f(A, B, i + 1, true);\n        return memo[shouldSwap][i] = min(o1, o2);\n    }\n    \n    int minSwap(vector<int> &A, vector<int> &B) {\n        memo.resize(2, vector<int> (A.size(), -1));\n        return min(f(A, B, 1, false), 1 + f(A, B, 1, true));\n    }\n};\n```
['C']