> For the complete documentation index, see [llms.txt](https://chiragjain.gitbook.io/neetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chiragjain.gitbook.io/neetcode/1899-merge-triplets-to-form-target-triplet/code.md).

# CODE

```python
class Solution:
    def mergeTriplets(self, triplets: List[List[int]], target: List[int]) -> bool:
        res = [-1, -1, -1]
        tx, ty, tz = target
        for x, y, z in triplets:
            # Fill the buckets till you have space If there 
            # is no space left in any of the buckets then stop
            if x <= tx and y <= ty and  z <= tz:
                res[0] = max(res[0], x)
                res[1] = max(res[1], y)
                res[2] = max(res[2], z)
        # Check if all the buckets are filled
        return all([a==x for a, x in zip(target, res)])
            
            
        
```
