The D. E. Shaw GroupOA #4
Find Maximum Beauty
估计中等评测数据准备中,可先阅读题面
考点(AI 标注)子序列
Given an array arr, you can perform the following operation:
- Remove an element from any position in the array. The order of other elements should be maintained after removing the element.
You're allowed to perform this operation until the
arrsize becomes1. Now the beauty of an array is equal to the number of elements wherea[i] = i(the array is 1 indexed). Given an array, find the maximum beauty after performing the above operation. Function Description Complete the functionfindMaximumBeautyin the editor.findMaximumBeautyhas the following parameter: int[] arr: an array of integers Returnsint: the maximum beauty of the array
Constraints
unknown for now
Example 1
Input:
arr = [1, 3, 2, 5, 4, 5, 3]
Output:
4
Explanation: Following the operations described in the problem statement:
- Remove the first
3, thenarrbecomes[1, 2, 5, 4, 5, 3]. - Remove
3, thenarrbecomes[1, 2, 5, 4, 5]. The beauty of the final array is4. (where a[i] = i).