|| ✅✅🙏Easiest Solution && Sliding Window Approach🙏✅✅ ||
Thanks for Upvote in Advance\u2B06\uFE0F\uD83D\uDE0A\uD83D\uDC95\n\n\n\n# Code\ncpp []\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& p, int k) {\
# Thanks for Upvote in Advance\u2B06\uFE0F\uD83D\uDE0A\uD83D\uDC95\n![image.png](https://assets.leetcode.com/users/images/08664976-673e-4cf4-a701-7f1b8e51c865_1733642210.3504405.png)\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& p, int k) {\n        int n = p.size(), ans = 0, s = 0;\n        vector<int>v(n);\n        for(int i = 0; i < n; i++){\n            while(p[i] - p[s] > k)s++;\n            ans = max(ans, i-s+1 + (s>0? v[s-1] : 0));\n            v[i] = max((i>0? v[i-1]:0), i-s+1);\n        }\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'Sliding Window', 'C++']