Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ada7cd3

Browse files
authoredAug 13, 2023
Create 1899-merge-triplets-to-form-target-triplet.c
1 parent 4ed8182 commit ada7cd3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bool mergeTriplets(int** triplets, int tripletsSize, int* tripletsColSize, int* target, int targetSize) {
2+
int x = 0, y = 0, z = 0;
3+
4+
for (int i = 0; i < tripletsSize; i++) {
5+
if (triplets[i][0] <= target[0] && triplets[i][1] <= target[1] && triplets[i][2] <= target[2]) {
6+
x = (x > triplets[i][0]) ? x : triplets[i][0];
7+
y = (y > triplets[i][1]) ? y : triplets[i][1];
8+
z = (z > triplets[i][2]) ? z : triplets[i][2];
9+
}
10+
}
11+
12+
return (x == target[0] && y == target[1] && z == target[2]);
13+
}

0 commit comments

Comments
 (0)
Please sign in to comment.