MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / min_max_game

Function min_max_game

2293-min-max-game.rs:1–16  ·  view source on GitHub ↗
(nums: Vec<i32>)

Source from the content-addressed store, hash-verified

1pub fn min_max_game(nums: Vec<i32>) -> i32 {
2 let mut nums = nums.clone();
3 while nums.len() > 1 {
4 let nums_chunks = nums.chunks(2);
5 let mut tmp = vec!();
6 for (i, chunk) in nums_chunks.enumerate() {
7 if i % 2 == 0 {
8 tmp.push(*chunk.iter().min().unwrap());
9 } else {
10 tmp.push(*chunk.iter().max().unwrap());
11 }
12 }
13 nums = tmp;
14 }
15 nums[0]
16}
17
18fn main() {
19 let nums = vec![1,3,5,2,4,8,2,2];

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected