Back to problems

Maximum Number of Distinct Elements After Operations

Algorithm · xAI · Medium

Largest Distinct Count After One Adjustment per Value Coding Software Engineer Given an integer array nums together with an integer k, determine how many unique values the array can contain at most. Each array entry may be modified no more than one time using this operation: Increase or decrease it by any integer amount from [-k, k]. Return the greatest achievable count of distinct numbers in nums once the allowed changes have been made. Examples Example 1: Input: nums =…

Checking your access…