CSES Removal Game

Photo by Claudio Schwarz | @purzlbaum on Unsplash

Welcome to part 8 of this series, in case you have missed part 7, here is the link: Part 7

Problem Statement:

There is a list of n numbers and two players who move alternately. On each move, a player removes either the first or last number from the list, and their score increases by that number. Both players try to maximize their scores.

What is the maximum possible score for the first player when both players play optimally?

Problem Link: https://cses.fi/problemset/task/1097

Input

The first input line contains an integer n: the size of the list.

The next line has…

Aaryamann Singh

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store