Simple DP 🚀 || C++ || TC: O(N*3)
\nint const N = 1e5;\nclass Solution {\npublic:\n    int dp[N+1][3];\n    int helper(int idx,int k,vector<int> &pp,int kk){\n        if(idx==pp.size()||k==0) re
```\nint const N = 1e5;\nclass Solution {\npublic:\n    int dp[N+1][3];\n    int helper(int idx,int k,vector<int> &pp,int kk){\n        if(idx==pp.size()||k==0) return 0;\n        if(dp[idx][k]!=-1) return dp[idx][k];\n        int ntk = helper(idx+1,k,pp,kk);\n        int index = lower_bound(pp.begin(),pp.end(),pp[idx]+1+kk)-pp.begin();\n        int tk = index-idx;\n        tk+= helper(index,k-1,pp,kk);\n        return dp[idx][k]=max(tk,ntk);\n    }\n    int maximizeWin(vector<int>& pp, int k) {\n        memset(dp,-1,sizeof(dp));\n        return helper(0,2,pp,k);\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']