Some problems cannot be solved left to right, because the decision that matters splits the input in the middle. Merging piles, cutting a board, taking cards from both ends of a row and keeping letters that mirror all ask for the best answer on a span from start to end, and that answer depends on smaller spans inside it.
Define best[start][end] for one span, then choose how the span splits. For merging, the last merge joins [start, mid] and [mid + 1, end]. For cutting, the first cut leaves two independent pieces. For a two-player game, the player to move takes an end and the opponent then plays best on the rest. When the first action changes its own neighbors, choose the last action inside the span instead, because its neighbors are fixed.
Fill spans by length, shortest first, or run start from right to left so every inner span is ready. With n^2 spans and up to n splits each, expect O(n^3) time and O(n^2) space, which is fine for a few hundred items.
Solve short spans first; each longer span tries every split.