Input: arr[] = {1, 2, 1, 4, 6, 4, 4}, L = 1, R = 5 and K = 2
Output: 6
Explanation:
Following are the operations performed on the given array elements:
1. Changing arr[2] to 3 modifies array to {1, 2, 3, 4, 6, 4, 4}
2. Changing arr[3] to 5 modifies array to {1, 2, 3, 5, 6, 4, 4}
As K = 2, no more changes can be done
Therefore, Distinct elements are {1, 2, 3, 5, 6, 4} and the number of maximum distinct elements is 6.
Input: arr[] = {1, 2, 1, 4, 6, 4, 4}, L = 1, R = 5 and K = 1
Output: 5
Explanation:
Following are the operations performed on the given array elements:
1. Changing arr[2] to 3 modifies array to {1, 2, 3, 4, 6, 4, 4}
As K = 1, no more changes can be done
Therefore, Distinct elements are {1, 2, 3, 6, 4} and the number of maximum distinct elements is 5.