rust: simple partition_point and max array, beats 100%
\n# Code\n\nimpl Solution {\n    pub fn maximize_win(prize_positions: Vec<i32>, k: i32) -> i32 {\n        let mut i = 0;\n        let mut cmax = vec![0; prize_p
\n# Code\n```\nimpl Solution {\n    pub fn maximize_win(prize_positions: Vec<i32>, k: i32) -> i32 {\n        let mut i = 0;\n        let mut cmax = vec![0; prize_positions.len() + 1];\n        let mut max = 0; // result\n        while i < prize_positions.len() {\n            let curr = prize_positions[i];\n            // locate the largest segment with k from i\n            let r = prize_positions.partition_point(|&x| x <= curr + k);\n            // length of segment\n            let wt = (r - i) as i32;\n            // update cmax for r - max of segment ending at r\n            // max of last max, current, or already ending ar r\n            cmax[r] = cmax[i].max(cmax[r].max(wt));\n            // update max with the max of last non overlapping segment\n            max = max.max(cmax[i] + wt);\n            // bubble up the max to all equal values for prizes\n            while i < prize_positions.len() && prize_positions[i] == curr {\n                i += 1;\n                cmax[i] = cmax[i].max(cmax[i - 1]);\n            }\n        }\n        max\n    }\n}\n```
['Rust']