2024-06-15发表2025-01-15更新LeetCode每日一题几秒读完 (大约92个字)0次访问2779. 数组的最大美丽值数组的最大美丽值 难度: medium 原始链接: https://leetcode.cn/problems/maximum-beauty-of-an-array-after-applying-operation 标签: 滑动窗口 解法一: 滑动窗口go123456789101112131415func maximumBeauty(nums []int, k int) int { sort.Ints(nums) left := 0 right := 0 n := len(nums) ans := 0 for right < n { for left <= right && nums[right]-nums[left] > (k<<1) { left++ } ans = max(ans, right-left+1) right++ } return ans} 2779. 数组的最大美丽值https://wuhunyu.top/leetcode/2024/06/maximum-beauty-of-an-array-after-applying-operation/index.html作者wuhunyu发布于2024-06-15更新于2025-01-15许可协议#滑动窗口