Brute-force
This question is the variation of Stone Game. Let’s start with the brute-force approach. Assume n = piles.length. If we enumerate all possible paths that a player choose either the start or the end stones in the array, players switch between different layers. Each path has a length of n. For each path, we can track the sum scores of two players. At the botom of the decision tree, we compare two player's scores:
