LC 1899 -- Problem

A triplet is an array of three integers. You are given a 2D integer array triplets where triplets[i] = [a, b, c] describes the i-th triplet. You are also given an integer array target = [x, y, z]. Return true if it is possible to obtain the target by choosing some triplets and replacing the target with the element-wise maximum of the chosen triplets.

Input: triplets = 253,183,521,335, target = 555
Output: true

The merge operation takes the element-wise maximum: for selected triplets, result[i] = max(t1[i], t2[i], ...) for each position.

Here is a puzzle that looks combinatorial. You have four triplets and a target 555. The “merge” operation takes the element-wise maximum of whichever triplets you select. Your job: find a subset whose merge equals the target exactly.

The brute-force approach tries every possible subset -- that is 2^n combinations. But there is a shortcut hiding in the math of the max operation. To find it, you need to hit the wall first. What happens when you get greedy and include ALL the triplets?

Tap triplets to include them in the merge, then check if the result matches the target. Try including every triplet -- see what breaks.

Target:
555

Tap triplets to include them in the merge.