C++ || easy solution || DP + Sliding Window || beats 88%
\n# Code\n\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& prizePositions, int k) {\n        int n = prizePositions.size(), start = 0, ans = 0;\n  
\n# Code\n```\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& prizePositions, int k) {\n        int n = prizePositions.size(), start = 0, ans = 0;\n        vector<int>dp(n);\n        for(int end=0; end<n; end++) {\n            while(prizePositions[end] - prizePositions[start] > k)\n                start++;\n\n            int curr_ans = end-start + 1;    \n            if(start > 0) {\n                curr_ans += dp[start-1];\n            }\n            ans = max(ans, curr_ans);\n\n            int prev = 0;\n            if(end > 0) prev = dp[end-1];\n            \n            dp[end] = max(prev, end-start+1);\n        }\n        return ans;\n    }\n};\n```
['C++']