fully explained c++ solution
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>& nums, int k) {\n        int n = nums.size();\n        vector<int>v(n);\n      // this vector store how much element if take nums[i] starting x-cordinates\n      // That means number of element between [nums[i],nums[i]+k];\n        for(int i = 0;i<nums.size();i++){\n                int x = upper_bound(nums.begin()+i,nums.end(),nums[i]+k) - nums.begin(); \n                v[i] = x - i;\n                cout<<v[i]<<" ";\n                 // as i mention above we store element between[nums[i],nums[i]+k]\n                 // suppose we take nums[i] = 1 at i = 0 in example 1 1 2 2 3 3 5\n                 //then x will be index = 6\n                 // we store at i = 0 in vector v;  6 that is number of element between [nums[i],nums[i]+k] (1 , 3);\n            } \n\n            //now v vector : - 6 5 5 3 3 2 1\n\n\n        vector<int>suff(n);\n        suff[n-1] = 1;\n        // suff vector store maximum number of prize we get if we chhose index i;\n        long long ans = 0;\n        for(int i = n-2;i>=0;i--){\n            suff[i] = max(suff[i+1],v[i]);\n        }\n        //now suff vector : - 1 2 3 3 4 5 6\n\n\n        //now for getting answer\n        for(int i = 0;i<n;i++){\n            //suppose you chhose index i = 1,then v[i]  = 5 means it have prize so 1 + 5 = 6 \n            // first segment is at i = 1 and second at 6\n            // and suff vector store maximum prize you can get at index 6 suff[i+v[i]] \n            if(i+v[i]<n){\n                ans = max(ans,1ll*(suff[i+v[i]]+v[i]));\n            }\n            ans = max(ans,1ll*(v[i]));\n        }\n        return ans;\n    }\n};\n```
['C++']