PINE LABS Hiring | Maximum Array Question Using Sliding Window and Sorting

Question · Posted Jun 2026

Problem Statement You are given an integer array nums and an integer k. For each element nums[i], you may perform at most one operation: Change nums[i] to any integer within 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. Example 1 Input nums = [4,6,1,2] k = 2 Output 3 Explanation ...

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

Log in Create a free account