first and second of the same even length n. Remove exactly n / 2 elements from each array, so that exactly half of each remains.
Then all remaining elements of both arrays are pooled together. Return the largest possible number of distinct values in that pool.first=[4, 4, 7, 7], second=[7, 7, 7, 9] → 3
Keep [4, 7] from first and [7, 9] from second. Together they give three distinct numbers: 4, 7 and 9.
first=[5, 5, 5, 5, 5, 5], second=[5, 5, 6, 6, 8, 8] → 3
first holds only fives, while second can keep 6 and 8. That makes 3 distinct numbers.
first=[1, 2, 3, 4], second=[1, 2, 3, 4] → 4
Keep 1 and 2 in the first array and 3 and 4 in the second, and all four numbers survive.
n ≤ 2·10⁴ and n is evenfirst.length = second.length = nfirst[i], second[i] ≤ 10⁹first=[4, 4, 7, 7], second=[7, 7, 7, 9]
3
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.