Skip to content

Practice Merge Triplets to Form Target Triplet

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1899
LeetCode Problem

Merge Triplets to Form Target Triplet

Problem Statement

One operation chooses different triplet indices i and j and replaces triplets[j] by the componentwise maximum of those two triplets, leaving triplets[i] available. Return whether some triplet can become exactly target after any number of operations, including zero.

Source: Merge Triplets to Form Target Triplet on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]
Output
true

# Example 2

Input
triplets = [[3,4,5],[4,5,6]], target = [3,2,5]
Output
false

# Example 3

Input
triplets = [[2,5,3],[2,3,4],[1,2,5],[5,2,3]], target = [5,5,5]
Output
true

Constraints

1 <= triplets.length <= 10^5
triplets[i].length == target.length == 3
1 <= ai, bi, ci, x, y, z <= 1000

Related LeetCode Problems

Practice more problems similar to Merge Triplets to Form Target Triplet.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.