Problem · Array
Maximize Array Beauty After Deletions
Learn this problemProblem statement
You are given an integer array values. Delete any number of elements while preserving the relative order of the elements that remain. At least one element must remain.
The beauty of the final array is the number of its 1-indexed positions i for which the value at that position equals i.
Return the maximum beauty obtainable after deletions.
Function
maximizeArrayBeauty(values: int[]) → intExamples
Example 1
values = [2,2,1,3,4]return = 3Delete the third element to obtain [2,2,3,4]. Its values match positions 2, 3, and 4.
Example 2
values = [4,1,2,3,4]return = 4Delete the first element. The remaining array is [1,2,3,4], so every position contributes to the beauty.
Example 3
values = [2,3,4,5]return = 0No non-empty subsequence can place any of these values at an equal 1-indexed position.
Constraints
1 <= values.length <= 200000-10^9 <= values[i] <= 10^9
More Point72 problems
- Simulate a Deterministic Finite AutomatonOA · Seen Aug 2026
- Initial Public OfferingOA · Seen Jul 2026
- Test the HypothesisOA · Seen Jul 2026
- Lexicographically Smallest String After Substring OperationOA · Seen May 2026
- Generate an Optimal Portfolio Trading ReportPHONE SCREEN · Seen Apr 2026
- Get Triplet CountOA · Seen Apr 2025