Tap here to switch tabs
Problem
Submissions

Problem: Maximize Score After Pair Deletions

med
30 min
Try to solve the Maximize Score After Pair Deletions problem.

Statement

You are given an integer array nums.

You can perform an operation where you delete two elements from nums by choosing one of the following options:

  • Delete the first two elements of nums.

  • Delete the last two elements of nums.

  • Delete the first element and the last element of nums.

The score of the operation is the sum of the two deleted elements.

Return the maximum score that can be obtained from performing this operation.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Score After Pair Deletions

med
30 min
Try to solve the Maximize Score After Pair Deletions problem.

Statement

You are given an integer array nums.

You can perform an operation where you delete two elements from nums by choosing one of the following options:

  • Delete the first two elements of nums.

  • Delete the last two elements of nums.

  • Delete the first element and the last element of nums.

The score of the operation is the sum of the two deleted elements.

Return the maximum score that can be obtained from performing this operation.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4