Given a list of triplets and a target triplet, determine whether you can choose a subset of the triplets and merge them — taking the elementwise maximum across all chosen triplets — to form exactly the target triplet. A triplet is only safe to use if none of its values exceed the corresponding target value.
triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]trueSolve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Make the choice that looks best right now, without reconsidering it later, and trust that a sequence of locally optimal choices adds up to a globally optimal answer. It only works when the problem actually has that property.
Original problem on LeetCode ↗