This is a function problem. The input is already taken care of by the driver code. You only need to complete the function maxDistinctNum() that takes an array (arr), sizeOfArray (n), integer value K, and return the maximum distinct elements after removing K elements. The driver code takes care of the printing.
Expected Time Complexity: O(K*logD) where D is the number of distinct elements in the given array. Expected Auxiliary Space: O(N).