#3434
Maximum Frequency After Subarray Operation
expert · 1115 · lc medium +32 · 30.9% accepted · 266 likes · top 8%
Description
You are given an array nums of length n and an integer k.
Perform the following operation exactly once:
- Choose a subarray nums[i..j] (where 0 <= i <= j <= n - 1).
- Choose an integer x and add x to every element in nums[i..j].
Find the maximum frequency of the value k in nums after the operation.
Code
1
2
3