← ALL NOTES
Array

486. Predict the Winner

The move that makes this tractable is to stop tracking two separate scores and track a single number: how far ahead the player to move can get over the opponent on a slice of the array. Player 1 wins exactly when that margin over the whole array is at least 0.

Loading…