Company: Ion_Group_Dev_Test_LDP_Class_2026-Referrals
Difficulty: medium
Problem Description Consider two arrays, a and b, each containing n integers. You can perform the following operation at most k times: Select two indices, i and j (0 ≤ i,j < n), and swap the elements a[i] and b[j]. Your task is to determine the maximum number of distinct elements that can be achieved in array a after performing at most k such operations. Complete the function getMaximumDistinctCount in the editor with the following parameters: int a[n]: an array of integers int b[n]: an array of integers int k: the maximum number of operations Returns int: the maximum number of distinct elements in a after at most k operations Examples Example 1 Input n = 5 a = [2, 3, 3, 2, 2] b = [1, 3, 2, 4, 1] k = 2 Output: 4 Explanation: To get the maximum number of distinct elements in array a: Select i = 2, j = 0. Swap a[2] and b[0]. Now, a = [2, 3, 1, 2, 2] and b = [3, 3, 2, 4, 1]. Select i = 4, j = 3. Swap a[4] and b[3]. Finally, a = [2, 3, 1, 2, 4] and b = [3, 3, 2, 2, 1]. Now a = [2, 3, 1,