← All problemsSign in

Coins

There are N piles of coins. Two players play alternately. In each turn, a player can remove any number of coins from a non-empty pile. At least one coin must be removed. The player who picks the last coin from the last non empty pile wins the game. It is currently your opponent’s turn. You suddenly realize that you would lose the game if he played optimally. So while he is not looking, you decide

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start