You are given an integer array cardPoints, where each element represents the points on a card in a row. You must take exactly k cards. On each move, you may take one card from either the beginning or the end of cardPoints.
Return the maximum total points you can obtain after taking exactly k cards.
Constraints:
cardPoints.length
cardPoints[i]
k cardPoints.length
You are given an integer array cardPoints, where each element represents the points on a card in a row. You must take exactly k cards. On each move, you may take one card from either the beginning or the end of cardPoints.
Return the maximum total points you can obtain after taking exactly k cards.
Constraints:
cardPoints.length
cardPoints[i]
k cardPoints.length