#2974
Minimum Number Game
newbie · 125 · lc easy +13 · verified · 85.4% accepted · 342 likes · top 97%
Description
You are given an even-length integer array nums and an empty output array arr. Each round: Alice picks the current minimum of nums, then Bob picks the new minimum. Bob's pick is appended to arr first, then Alice's.
Repeat until nums is empty and return arr.
Example 1:
Input: nums = [5,4,2,3]
Output: [3,2,5,4]
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].
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].
Example 2:
Input: nums = [2,5]
Output: [5,2]
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].
Code
1
2
3