NeetCode #251LC-2779MediumSliding Window
← Back to All Problems

#251 · #2779 · Maximum Beauty of an Array After Applying Operation(数组的最大美丽值)

📌 Problem Statement & Constraints

You are given a 0-indexed integer array nums and a non-negative integer k. In one operation you may choose an index and replace nums[i] with any integer in [nums[i] - k, nums[i] + k]. Return the maximum beauty of the array: the length of the longest subsequence whose elements can all be made equal. Constraints: 1 <= nums.length <= 10^5, 0 <= nums[i] <= 10^5, 0 <= k <= 10^5.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!