max_count to store the maximum frequency of any element in the array.max_count accordingly.distinct_count = len(nums) - max_count.distinct_count is greater than or equal to max_count, the result is 0 if the array length is even, or 1 if the array length is odd.distinct_count is less than max_count, the result is max_count - distinct_count.