C++ Solution Queue
Code\n\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& prizePositions, int k) \n    {\n        int f[3];\n        f[0]=f[1]=f[2]=0;\n        queue<
# Code\n```\nclass Solution {\npublic:\n    int maximizeWin(vector<int>& prizePositions, int k) \n    {\n        int f[3];\n        f[0]=f[1]=f[2]=0;\n        queue<int>q1;\n        queue<pair<int,int>>q2;\n        for(auto &x:prizePositions)\n        {\n            f[0]+=1;\n            q1.push(x);\n            while(q1.size()&&q1.front()<x-k)\n            {\n                f[0]-=1;\n                q1.pop();\n            }\n            q2.push({x,f[0]});\n            while(q2.size()&&q2.front().first<x-k)\n            {\n                f[1]=max(f[1],q2.front().second);\n                q2.pop();\n            }\n            f[2]=max(f[2],f[1]+f[0]);\n        }\n        return max({f[0],f[1],f[2]});\n    }\n};\n```
['Queue', 'C++']