Most Frequent Even Element
Given an integer array nums, return the most frequent even element.
If there is a tie, return the smallest one. If there is no such element, return -1.
Example 1
Input
nums = [0,1,2,2,4,4,1]Output
2The even elements are 0, 2, and 4; 2 and 4 appear the most, so the smallest one, 2, is returned.
Example 2
Input
nums = [4,4,4,9,2,4]Output
44 is the even element that appears the most.
Constraints
- 1 <= nums.length <= 2000
- 0 <= nums[i] <= 10^5