#3397
Maximum Number of Distinct Elements After Operations
medium · 52.2% accepted · 559 likes · top 42%
Description
You are given an integer array nums and an integer k.
You are allowed to perform the following operation on each element of the array at most once:
- Add an integer in the range [-k, k] to the element.
Return the maximum possible number of distinct elements in nums after performing the operations.
Solution