A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain.
To obtain target, you may apply the following operation any number of times:
i and j (0-indexed) where i != j and update triplets[i] to become [max(ai, aj), max(bi, bj), max(ci, cj)].Return true if it is possible to obtain the target triplet [x, y, z] as an element of triplets after performing the above operations, or false otherwise.
Input: triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5]], target = [2, 7, 5] Output: true Explanation: Merge triplets [2, 5, 3] and [1, 7, 5]: max(2,1) = 2, max(5,7) = 7, max(3,5) = 5 -> [2, 7, 5].
Input: triplets = [[3, 4, 5], [4, 5, 6]], target = [3, 2, 5] Output: false Explanation: No valid triplet exists because every triplet has a value exceeding target in some position.
triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5]], target = [2, 7, 5]