Catch Up
We can run the first [l1, r1] and the second [l2, r2] sliding windows at the same time.\n\nAs r2 < l1, the second window catches up as the first one moves.\n\nW
We can run the first `[l1, r1]` and the second `[l2, r2]` sliding windows at the same time.\n\nAs `r2 < l1`, the second window catches up as the first one moves.\n\nWe track the maximum win we can get from the second window (`max_w2`) so far.\n\nThe win from the first window is `w1`, and we return the best result we can get from `w1 + max_w2`.\n\n**C++**\n```cpp\nint maximizeWin(vector<int>& p, int k) {\n    int res = 0, w1 = 0, w2 = 0, max_w2 = 0;\n    for (int l1 = 0, r1 = 0, l2 = 0, r2 = 0; r1 < p.size(); ++r1) {\n        ++w1;\n        for(; p[r1] - p[l1] > k; ++l1)\n            --w1;\n        for(; r2 < l1; ++r2) {\n            ++w2;\n            for (; p[r2] - p[l2] > k; ++l2)\n                --w2;\n            max_w2 = max(max_w2, w2);\n        }\n        res = max(res, w1 + max_w2);\n    }\n    return res;\n}\n```
['C']