Maximize Beauty

Problem Overview

  • Maximize the array’s beauty by deleting elements (order preserved), where beauty is the count of indices i with a[i] == i in the final array.
  • Input: arr of n integers; Output: an integer for maximum beauty; Constraints: 1 ≤ n ≤ 2000, 1 ≤ arr[i] ≤ 100000.
  • Domain: array indexing, subsequence selection, and fixed-point counts relevant to data alignment scenarios.
  • From Mathworks interviews; a classic coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: