Find Maximum Beauty
Updated
Problem statement
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 arr size becomes 1.
Now the beauty of an array is equal to the number of elements where a[i] = i (the array is 1 indexed).
Given an array, find the maximum beauty after performing the above operation.
Function
findMaximumBeauty(arr: int[]) → int
Complete the function findMaximumBeauty in the editor.
findMaximumBeauty has the following parameter:
int[] arr: an array of integers
Returns
int: the maximum beauty of the array
Examples
Example 1
arr = [1, 3, 2, 5, 4, 5, 3]return = 4Following 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 is 4. (where a[i] = i).
Constraints
unknown for now
More The D.E. Shaw Group interview questions
- IPOPHONE SCREEN · Seen Nov 2026
- Print Numbers in Turn with Three ThreadsPHONE SCREEN · Seen Nov 2026
- Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
- Koko Eating BananasPHONE SCREEN · Seen Nov 2026
- Sum of Smallest Non-DivisorsPHONE SCREEN · Seen Nov 2026
- Count Lucky TicketsOA · Seen Nov 2026
- Count Palindrome Addition ChoicesOA · Seen Nov 2026
- Coordinate Odd and Even Workers in OrderONSITE INTERVIEW · Seen Oct 2026
- Minimum Taps to Water a GardenONSITE INTERVIEW · Seen Oct 2026
- Remove the Fewest Magic BeansPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Minimum Non-Adjacent Selection CapabilityMicrosoft · OAMicrosoft interview questions
- Earn the Most 🐝Capital One · OACapital One interview questions
- Minimum Cost to Merge Values into OnePayPal · OAPayPal interview questions
- Minimum Operations to Sort with Rotations Then SwapsBank of New York Mellon · OA
- Minimum Cost of Left and Right PropagationAmazon · OA
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Reschedule Meetings for Maximum Free TimeFivetran · OAFivetran interview questions
- Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
- Maximum ScoreNVIDIA · OANVIDIA interview questions
- Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA