Merge Triplets to Form Target (#1899)
A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the i-th triplet. You are also given an integer array target = [x, y, z] that represents the triplet we want to obtain.
To obtain the target triplet, you may apply the following operation any number of times:
- Choose two different indices
iandjand update thej-th triplet to be[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, or false otherwise.
Company Tags: Google
Core Concept: Greedy Algorithm