Maximum Beauty of an Array After Applying Operation | Leetcode 2779