The Only DP Solution || Sliding Window
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& p, int k) {\n        int n = p.size();\n        vector<int> dp(n,0);\n        int ans = 0;\n\n        int i = 0,j = 0;\n\n        while(j < p.size()){\n            while(p[j]-p[i] > k){\n                i++;\n            }\n\n            if(i > 0){\n                ans = max(ans,j-i+1+dp[i-1]);\n            }\n            else{\n                ans = max(ans,j-i+1);\n            }\n            \n            if(j > 0){\n                dp[j] = max(dp[j-1],j-i+1);\n            }\n            else{\n                dp[j] = j-i+1;\n            }\n            j++;\n        }\n        return ans;\n    }\n};\n```
['C++']