Merging triplets a and b gives [max(a0,b0), max(a1,b1), max(a2,b2)]. Given a list of triplets and a target triplet, return true if some sequence of merges can produce the target as one of the triplets.
Only the three target values matter. Among safe triplets (nothing above the target), note which positions hit the target value exactly. All three must be covered.
1function mergeTriplets(triplets: number[][], target: number[]): boolean {2const hit = [false, false, false];3for (const t of triplets) {4if (t.some((v, k) => v > target[k])) continue;5t.forEach((v, k) => { if (v === target[k]) hit[k] = true; });6}7return hit.every(Boolean);8}
No position covered yet.
Space: play/pause · ←/→: step