Company: Deshaw
Difficulty: medium
Maximize Codebase Beauty In a software project, the \"beauty\" of a codebase is defined as the number of modules whose performance score exactly matches their module index. Given an array modules of size n where modules[i] is defined as the performance score of the i th module, a developer can improve the beauty of the codebase by removing any module, ensuring that the order of the remaining modules is preserved. Find the maximum possible beauty of the codebase after performing this operation any number of times. Example Given n = 7, modules = [1, 3, 2, 5, 4, 5, 3] One optimal sequence of improvements is shown below: Remove the module at index 1 with a performance score of 3; the updated list is [1, 2, 5, 4, 5, 3]. Remove the module at new index 5 with a performance score of 3; the updated list is [1, 2, 5, 4, 5]. The beauty of the codebase is 4 since: modules[1] = 1 modules[2] = 2 modules[4] = 4 modules[5] = 5 Note that there can be more than one final array with maximum beauty, like