Javascript - DP + Sliding Window
Code\n\n/**\n * @param {number[]} prizePositions\n * @param {number} k\n * @return {number}\n */\nvar maximizeWin = function (prizePositions, k) {\n  const n = 
# Code\n```\n/**\n * @param {number[]} prizePositions\n * @param {number} k\n * @return {number}\n */\nvar maximizeWin = function (prizePositions, k) {\n  const n = prizePositions.length;\n  const dp = new Array(n + 1).fill(0);\n  let ans = 0;\n  let start = 0;\n\n  for (let end = 0; end < prizePositions.length; end++) {\n    while (prizePositions[end] - prizePositions[start] > k) start++;\n\n    const currPrize = end - start + 1;\n    dp[end + 1] = Math.max(dp[end], currPrize);\n    ans = Math.max(ans, currPrize + dp[start]);\n  }\n\n  return ans;\n};\n\n```
['JavaScript']