Skip to content

Practice Maximum Number of Operations With the Same Score II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3040
LeetCode Problem

Maximum Number of Operations With the Same Score II

Problem Statement

Given nums, an operation removes either its first two elements, its last two elements, or its first and last elements. The score is the sum of the two removed values. All operations must have the same score. Return the maximum number of operations that can be performed.

Source: Maximum Number of Operations With the Same Score II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,2,1,2,3,4]
Output
3

# Example 2

Input
nums = [3,2,6,1,4]
Output
2

Constraints

2 <= nums.length <= 2000
1 <= nums[i] <= 1000

Related LeetCode Problems

Practice more problems similar to Maximum Number of Operations With the Same Score II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.