Rust Solution using Sliidng Window and DP
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n\nimpl Solution {\n  pub fn maximize_win(prize_positions: Vec<i32>, k: i32) -> i32 
# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nimpl Solution {\n  pub fn maximize_win(prize_positions: Vec<i32>, k: i32) -> i32 {\n    let n = prize_positions.len();\n    if n == 1 {\n      return 1\n    }\n\n    let mut memo = vec![0;n];\n    let mut max = 0;\n    let mut ri = 0;\n    for li in 0..n {\n      while ri < n && prize_positions[ri] - prize_positions[li] <= k {\n        ri += 1;\n        let score = ri - li;\n        max = max.max(score);\n        memo[ri-1] = memo[ri-1].max(max);\n      }\n\n      if ri == n {\n        break\n      }\n    }\n\n    let mut result = 0;\n    let mut li = (n-1) as i32;\n    for ri in (1..n).rev() {\n      while 0 <= li && prize_positions[ri] - prize_positions[li as usize] <= k {\n        li -= 1;\n        let score = ri - li as usize;\n        if 0 <= li {\n          result = result.max(score + memo[li as usize]);\n        }\n      }\n    }\n\n    result as i32\n  }\n}\n```
['Dynamic Programming', 'Sliding Window', 'Rust']