You are given an array nums and an integer k.
For every element in the array, you may change it at most once by adding any integer value between -k and k (inclusive).
Your goal is to maximize the number of unique (distinct) values in the array after optionally modifying the elements.
Return the maximum possible count of distinct numbers you can achieve.
Input: nums = [5,5,6,6,6], k = 1
Output: 4
Explanation:
Modify values to: [4, 5, 6, 7, 8] Now there are 4 distinct values → {4,5,6,7,8}
Input: nums = [10,10,10], k = 2
Output: 3
Explanation:
Changes could be: [8,10,12] We get 3 different numbers.
Accepted:
Submission: