Ctrl K

The Most Common Even Value

Easy
You get an integer array values. Among its even elements, find the one that occurs most often. If several are tied, return the smallest. If there are no even elements at all, return -1.
Example 1
values=[6, 3, 8, 6, 8, 5] → 6

The even values are 6 and 8, both appearing twice; the smaller is 6.

Example 2
values=[10, 7, 10, 2, 10] → 10

10 appears three times, more than any other even value.

Example 3
values=[1, 9, 15] → -1

There are no even values.

Constraints
  • 1 ≤ len(values) ≤ 2000
  • 0 ≤ values[i] ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Candidate With Most Votes EasyValues One Apart EasyEven Piles of Cards EasyMatching Domino Tiles EasyWords From Letter Tiles Easy
loading Python…
Input
values=[6, 3, 8, 6, 8, 5]
Expected
6

Run checks the first 3 tests in your browser. Submit checks all 110 tests on the server, hidden ones included.