Problem · Dynamic Programming
Maximum Equal Deletion Sum
Learn this problemProblem statement
You have an array A, of size N. There are 3 ways to delete elements:
The array size should be greater than 2, if less, you cannot make any move. The question is to find in how many (maximum) moves, you can get deletion of equal sum.
Function
maximumEqualDeletionSum(A: int[]) → intExamples
Example 1
A = [1, 9, 8, 9, 5, 1, 2]return = 3You delete:
- first 2 elements (1,9) = 10
- first and last (8,2) = 10
- first and last (9,1) = 10
So, total 3 moves, 3 is the answer.
Constraints
🍋🍋🍊🍊