c++ easy memonization DP
\nclass Solution {\npublic:\n    int dp[100005][5];\n    int help(vector<int>&a,vector<int>&b,int i,int s){\n        if(i==a.size())return 0;\n        if(dp[i][
```\nclass Solution {\npublic:\n    int dp[100005][5];\n    int help(vector<int>&a,vector<int>&b,int i,int s){\n        if(i==a.size())return 0;\n        if(dp[i][s]!=-1)return dp[i][s];\n        int r=INT_MAX;\n        if(s){                    //previous element was swapped\n            if(i-1>=0&&a[i]>b[i-1]&&b[i]>a[i-1]) r=min(r,help(a,b,i+1,0));\n            if(i-1>=0&&b[i]>b[i-1]&&a[i]>a[i-1]) r=min(r,1+help(a,b,i+1,1));      //we are swapping ith element\n            if(i==0) r=min({r,help(a,b,i+1,0),1+help(a,b,i+1,1)}); \n        }else{\n            if(i-1>=0&&a[i]>a[i-1]&&b[i]>b[i-1]) r=min(r,help(a,b,i+1,0));\n            if(i-1>=0&&a[i]>b[i-1]&&b[i]>a[i-1]) r=min(r,1+help(a,b,i+1,1));\n            if(i==0) r=min({r,help(a,b,i+1,0),1+help(a,b,i+1,1)});\n        }\n        return  dp[i][s]=r;\n         \n    }\n    int minSwap(vector<int>& nums1, vector<int>& nums2) {\n        memset(dp,-1,sizeof(dp));\n        return help(nums1,nums2,0,0);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C']