Kindly press F*** for this question :) || Clean Code
Don\'t use int for this question :)\n\n\nclass Solution {\npublic:\n    \n    unordered_map<int,int> m1,m2;\n    vector<long long int> n1,n2;\n    int md=100000
Don\'t use int for this question :)\n\n```\nclass Solution {\npublic:\n    \n    unordered_map<int,int> m1,m2;\n    vector<long long int> n1,n2;\n    int md=1000000007;\n    \n    long long int dp[100005][2][2];\n    \n    long long int ans(long long int pos,long long int f,long long int f2)\n    {   \n        if(f==1)\n        {            \n            if(pos>=n2.size())\n            {\n                return 0;\n            }\n        }\n        if(f==0)\n        {\n            if(pos>=n1.size())\n            {\n                return 0;\n            }\n        }\n        \n        if(dp[pos][f][f2]!=-1)\n        {\n            return (long long int)dp[pos][f][f2];\n        }\n        \n        if(f==0)\n        {\n            if((m2.find(n1[pos])!=m2.end())&&(f2==0))\n            {\n                dp[pos][f][f2]=max((long long int)ans(m2[n1[pos]],1,1),(long long int)(n1[pos]+ans(pos+1,0,0)));\n            }\n            else\n            {\n                dp[pos][f][f2]=(long long int)(n1[pos]+ans(pos+1,0,0));\n            }\n            return dp[pos][f][f2];\n        }\n        \n        if((m1.find(n2[pos])!=m2.end())&&(f2==0))\n        {\n            dp[pos][f][f2]=max((long long int)ans(m1[n2[pos]],0,1),(long long int)(n2[pos]+ans(pos+1,1,0)));\n        }\n        else\n        {\n            dp[pos][f][f2]=(long long int)(n2[pos]+ans(pos+1,1,0));\n        }\n        return dp[pos][f][f2];\n        \n    }\n    \n    int maxSum(vector<int>& nums1, vector<int>& nums2) {\n        \n        for(int i=0;i<nums1.size();i++)\n        {\n            n1.push_back((long long int)(nums1[i]));\n            m1[nums1[i]]=i;\n        }\n        for(int i=0;i<nums2.size();i++)\n        {\n            n2.push_back((long long int)(nums2[i]));\n            m2[nums2[i]]=i;\n        }\n        \n        memset(dp,-1,sizeof(dp));\n        long long int an= max(ans(0,0,0),ans(0,1,0));\n        return an%md;\n        \n    }\n};\n```
[]