You are given an integer array nums and an integer k.
You are allowed to perform exactly one operation:
Choose a subarray nums[i..j].
Choose an integer x.
Add x to each element in the selected subarray.
After performing the operation, some elements in the array might become equal to k.
Your task is to maximize the number of elements equal to k after this operation.
Return the maximum possible frequency of k after the operation.
Input: nums = [5, 5, 5], k = 5
Output: 3
Explanation:
No operation needed. k already appears 3 times.
Input: nums = [2, 4, 6, 8], k = 6
Output: 2
Explanation:
Add 4 to nums[0..1] → [6, 8, 6, 8] Now 6 appears twice.
Accepted:
Submission: