#1899
Merge Triplets to Form Target Triplet
medium· Greedyruns: 0You are given a list of integer triplets and a target triplet. To obtain the target, you may repeatedly pick two triplets and replace them with the elementwise maximum of the two. Return true if it is possible to obtain the target triplet, otherwise false.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 404
class Solution:
def mergeTriplets(
self, triplets: list[list[int]], target: list[int]
) -> bool:
good = [False, False, False]
for t in triplets:
if t[0] > target[0] or t[1] > target[1] or t[2] > target[2]:
continue
for i in range(3):
if t[i] == target[i]:
good[i] = True
return all(good)
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.