Maximum Points You Can Obtain from Cards
Medium · Arrays & Strings · about 15 minutes
Asked at Amazon, Google, Uber, Microsoft, ByteDance.
Cards are in a row; cardPoints[i] is a card's value. In each of k steps you take one card from either the beginning or the end of the row. Return the maximum total value you can take.