deno.land / x / masx200_leetcode_test@10.6.5 / most-frequent-even-element / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { counter } from "../substring-with-concatenation-of-all-words/counter.ts";
export default mostFrequentEven;function mostFrequentEven(nums: number[]): number { const evens = nums.filter((a) => !(a % 2)); if (evens.length === 0) return -1; const cnt = counter(evens);
const freq = Math.max(...cnt.values()); return Math.min( ...[...cnt.entries()].filter(([_k, v]) => v === freq).map((a) => a[0]), );}
masx200_leetcode_test

Version Info

Tagged at
a year ago