This question evaluates algorithmic problem-solving skills in game-theoretic optimal play and dynamic programming, including reasoning about maximum score difference, reconstruction of an optimal move sequence, and analysis of time and space complexity.
Given a row of N cards with integer values (values may be positive, zero, or negative), two players alternately pick either the leftmost or rightmost card. Both play optimally to maximize their total sum. Implement a function winner_score(cards: List[int]) -> int that returns the maximum score difference (first − second). Then: