values and candidates. For each candidate d, count how many elements of values are divisible by d with no remainder (repeated values count separately).
Return the candidate with the highest count. If several candidates tie for the top, return the smallest of them.values=[12, 18, 25, 30], candidates=[4, 6, 5] → 6
Only 12 is divisible by 4; 12, 18 and 30 are divisible by 6; 25 and 30 by 5. 6 wins.
values=[7, 11], candidates=[9, 2, 3] → 2
No value is divisible by any candidate, so they all score zero and the smallest one, 2, is returned.
values=[10, 20, 40], candidates=[20, 10, 5] → 5
values), len(candidates) ≤ 1000values[i], candidates[j] ≤ 10⁹values=[12, 18, 25, 30], candidates=[4, 6, 5]
6
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.