PINE LABS Hiring| Off-Campus OA (2023) | Maximum Beauty of an Array After Applying Operation

Question · Posted Jun 2026

Problem Statement You are given an integer array nums and an integer k. For each element nums[i], you can perform at most one operation: Change nums[i] to any integer value in the range [nums[i] - k, nums[i] + k] The beauty of the array is defined as the length of the longest subsequence consisting of equal elements after performing the operations. Return the maximum possible beauty of the array. Input Format Integer array nums Integer k Example 1 Input: nums ...

The full answer & interview discussion are available to premium members.

Log in Create a free account