Skip to content

Commit 2ef8e56

Browse files
authored
Merge pull request #2837 from mdmzfzl/main
Create: 1899-merge-triplets-to-form-target-triplet.c
2 parents 6946c3e + ada7cd3 commit 2ef8e56

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
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)