There is an integer array and 2 variables Q and M.The output required is the number which has the maximum frequency in the array, but the catch is that each number in the array can be increased/decreased by M and that too Q number of times.
In case of multiple answers print the first one.
array:1,2,3,4 and Q=1,M=1
Answer:3 ,as the array can be transformed into 2,2,2,4 (here 2 appears 3 times in this array, adding 1 in 1 and subtracting 1 from 3.)
A hashtable can be used here,but can't understand how to handle the addition and subtraction of each number of the array.
Can anyone please suggest an approach for that part?