package com.xxx.amp.magenta.livecodebench.solution;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class NumberGameSolution {
    public List<Integer> numberGame(List<Integer> nums) {
        List<Integer> arr = new ArrayList<>();
        Collections.sort(nums); // Sort the nums array to easily get the minimum elements
        
        for (int i = 0; i < nums.size(); i += 2) {
            // Alice removes the minimum element
            int aliceRemoved = nums.get(i);
            // Bob removes the next minimum element
            int bobRemoved = nums.get(i + 1);
            
            // Bob appends his removed element first
            arr.add(bobRemoved);
            // Alice appends her removed element next
            arr.add(aliceRemoved);
        }
        
        return arr;
    }
}
