deno.land / x / masx200_leetcode_test@10.6.5 / check-array-formation-through-concatenation / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { isEqual } from "../deps.ts";
function canFormArray(arr: number[], pieces: number[][]): boolean { const map = new Map<number, number>();
for (const [i, n] of arr.entries()) { map.set(n, i); }
pieces.sort((a, b) => (map.get(a[0]) ?? 0) - (map.get(b[0]) ?? 0));
return isEqual(arr, pieces.flat());}export default canFormArray;
masx200_leetcode_test

Version Info

Tagged at
a year ago