Official algorithmic problem description and constraints.
Alice and Bob play yet another game on an array π of size π. Alice starts with an empty array π. Both players take turns playing, with Alice starting first.
On Alice's turn, she picks one element from π, appends that element to π, and then deletes it from π.
On Bob's turn, he picks one element from π, and then deletes it from π.
The game ends when the array π is empty. Game's score is defined to be the MEX of π Alice wants to maximize the score while Bob wants to minimize it. Find game's final score if both players play optimally.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.