c++ solution dp memoization
\nclass Solution {\npublic:\n    long long range=0;\n    long long n;\n    long long dp[100500][3];\n    int find(vector<int>&nums,int index,int count)\n    {\n
```\nclass Solution {\npublic:\n    long long range=0;\n    long long n;\n    long long dp[100500][3];\n    int find(vector<int>&nums,int index,int count)\n    {\n        if(count==0||index>=n)\n        {\n            return 0;\n        }\n        if(dp[index][count]!=-1)\n        {\n            return dp[index][count];\n        }\n        long long ans=find(nums,index+1,count);\n        long long it=upper_bound(nums.begin(),nums.end(),nums[index]+range)-nums.begin();\n        ans=max(ans,it-index+find(nums,it,count-1));\n        return dp[index][count]= ans;\n    }\n    int maximizeWin(vector<int>& prizePositions, int k) \n    {\n        memset(dp,-1,sizeof(dp));\n        n=prizePositions.size();\n        range=k;\n        return find(prizePositions,0,2);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']