Company: Msci_28july
Difficulty: medium
Maximize Beauty of an Array Problem Description The beauty of an array is defined as the number of elements whose value equals their position index (1-indexed). Given an array of integers, you can perform the following operation any number of times while the array length is greater than 1: Choose any position i and delete the element at that position without changing the order of the remaining elements. Determine the maximum possible beauty that can be achieved. Complete the function maximizeBeauty in the editor with the following parameters: int arr[n] : the given array Returns: int : the maximum possible beauty of the array Examples Example 1: Input: n = 6, arr = [6, 3, 2, 4, 3, 4] Output: 3 Explanation: One optimal sequence of operations is shown. Choose i = 2 , delete arr[2] = 3 ; arr = [6, 2, 4, 3, 4] . Choose i = 3 , delete arr[3] = 4 ; arr = [6, 2, 3, 4] . In the final array [6, 2, 3, 4] , arr[2] = 2 , arr[3] = 3 , and arr[4] = 4 . The beauty is 3. Example 2: Input: n = 4, arr =