Cards From the Ends
Cards are in a row with values points. In each of k moves you take one card from the left end or the right end. Return the maximum total you can collect.
Requirements
- : equivalently, find the minimum-sum window of length that you leave behind.
Examples
EXAMPLE WALKTHROUGHtake from the right
A guided view of the published example, not a trace of your code.
INPUT
[[1,2,3,4,5,6,1],3]TASKcards_from_the_ends()
EXPECTED OUTPUT
12Start with the input values shown in this example.
Example 1 of 3
Input: points = [1,2,3,4,5,6,1], k = 3
Output: 12
Explanation: take from the right
Input: points = [2,2,2], k = 2
Output: 4
Explanation: equal
Input: points = [9,7,7,9,7,7,9], k = 7
Output: 55
Explanation: take all
Hint 1
Start by taking the first k cards, then swap them one at a time for cards from the right end.