Question: You are given a 0 - indexed array arr of N positive integers and two integers K and x . Find the maximum frequency of

You are given a 0-indexed array arr of N positive integers and two
integers K and x. Find the maximum frequency of any element(not
necessary to be present in the array) you can make after performing the
below operation at most K times-
Choose an index i and replace arr[i] with any integer from the range
[arr[i]-x,arr[i]+x]
Note: You are allowed to perform the operation on each index at most
once.
Example 1:
Input:
N=4,K=2,x=2
arr ={1,2,3,4}
Output: 3
Explanation:
After performing the operation on index 1 and 2.
Andifind
 You are given a 0-indexed array arr of N positive integers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!