Maximum Number of Operations With the Same Score I
You are given an array of integers nums. Consider the following operation:
- Delete the first two elements of
numsand define the score of the operation as the sum of these two elements.
You can perform this operation until nums contains fewer than two elements. Additionally, the same score must be achieved in all operations.
Return the maximum number of operations you can perform.
Example 1
Input
nums = [3,2,1,4,5]Output
2The first two operations both have score 5, and then fewer than two elements remain.
Example 2
Input
nums = [1,5,3,3,4,1,3,2,2,3]Output
2The first two operations both have score 6, but the next operation would have score 5, so it cannot be performed.
Constraints
- 2 <= nums.length <= 100
- 1 <= nums[i] <= 1000