Most points from the ends of a row
Cards lie face up in a row, and cards[i] is the number of points on card i. You take exactly k cards, one at a time, and each must come from the left end or the right end of what is left of the row. Return the most points you can collect.
Points may be negative or zero; 0 <= k <= len(cards). Aim for O(k) time and O(1) extra space: adding up both ends again for every split is O(k²).
Besides the tests, one large input (16,000 cards, k = 8,000) with a ~150 ms limit (scaled to your device's speed): brute force won't pass.
Examples
max_points([1,2,3,4,5,6,1], 3)→12max_points([2,2,2], 2)→4max_points([9,7,7,9,7,7,9], 7)→55