deno.land / x / masx200_leetcode_test@10.6.5 / maximum-rows-covered-by-columns / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export default function maximumRows( mat: number[][], numSelect: number,): number { const n = mat[0].length; //const m = mat.length const rows = mat.map((v) => ([...v.keys()].filter((j) => v[j]))); let ans = 0;
for (const selected of combinations(Array(n).keys(), numSelect)) { const set = new Set(selected); const count = mat.filter((_v, i) => rows[i].every((j) => set.has(j)) ).length;
ans = Math.max(ans, count); } return ans;}import { combinations } from "https://deno.land/x/combinatorics@1.1.2/combinations.ts";
masx200_leetcode_test

Version Info

Tagged at
a year ago