LeetCode 1899. Merge Triplets to Form Target Triplet

1
2
3
4
5
6
7
8
9
10
class Solution {
public:
bool mergeTriplets(vector<vector<int>>& triplets, vector<int>& target) {
int x = target[0], y = target[1], z = target[2], a = 1, b = 1, c = 1;
for (auto& t : triplets)
if (t[0] <= x && t[1] <= y && t[2] <= z)
a = max(a, t[0]), b = max(b, t[1]), c = max(c, t[2]);
return a == x && b == y && c == z;
}
};