2974. Minimum Number Game Easy

@problem@discussion
#Array#Sorting#Heap (Priority Queue)#Simulation



1/**
2 * [2974] Minimum Number Game
3 *
4 * You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows:
5 * 
6 * 	Every round, first Alice will remove the minimum element from nums, and then Bob does the same.
7 * 	Now, first Bob will append the removed element in the array arr, and then Alice does the same.
8 * 	The game continues until nums becomes empty.
9 * 
10 * Return the resulting array arr.
11 *  
12 * <strong class="example">Example 1:
13 * 
14 * Input: nums = [5,4,2,3]
15 * Output: [3,2,5,4]
16 * Explanation: In round one, first Alice removes 2 and then Bob removes 3. Then in arr firstly Bob appends 3 and then Alice appends 2. So arr = [3,2].
17 * At the begining of round two, nums = [5,4]. Now, first Alice removes 4 and then Bob removes 5. Then both append in arr which becomes [3,2,5,4].
18 * 
19 * <strong class="example">Example 2:
20 * 
21 * Input: nums = [2,5]
22 * Output: [5,2]
23 * Explanation: In round one, first Alice removes 2 and then Bob removes 5. Then in arr firstly Bob appends and then Alice appends. So arr = [5,2].
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	2 <= nums.length <= 100
29 * 	1 <= nums[i] <= 100
30 * 	nums.length % 2 == 0
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/minimum-number-game/
36// discuss: https://leetcode.com/problems/minimum-number-game/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn number_game(nums: Vec<i32>) -> Vec<i32> {
42        vec![]
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_2974() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.