#3397

Maximum Number of Distinct Elements After Operations

specialist · 835 · lc medium +31 · 52.2% accepted · 559 likes · top 42%

Description

You are given an integer array nums and an integer k.

You may apply the following operation to each element at most once:

- Add any integer from the range [-k, k] to the element.

Return the maximum number of distinct values that can appear in nums after performing the operations.

Code

1
2
3