-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/merge-triplets-to-form-target
Solution was accepted when It shouldn't be.
`class Solution:
def mergeTriplets(self, triplets: List[List[int]], target: List[int]) -> bool:
t1 = t2 = t3 = 0
t1min = triplets[0][0]
t2min = triplets[0][1]
t3min = triplets[0][2]
for x, y, z in triplets:
if x == target[0]:
t1 += 1
if y == target[1]:
t2 += 1
if z == target[2]:
t3 += 1
t1min = min(t1min, x)
t2min = min(t2min, y)
t3min = min(t3min, z)
if not t1 or not t2 or not t3:
return False
res1 = res2 = res3 = False
if t1 > 1 or (t1 == 1 and target[0] > t1min) or len(triplets) == 1:
res1 = True
if t2 > 1 or (t2 == 1 and target[1] > t2min) or len(triplets) == 1:
res2 = True
if t3 > 1 or (t3 == 1 and target[2] > t3min) or len(triplets) == 1:
res3 = True
return res1 and res2 and res3
`
This solution was accepted, but when I introduce a test case like so:
triplets=[[1,5,3], [7,2,1], [1,1,1]] target=[7,2,3]
It fails the test case. Add this as a test case?

Metadata
Metadata
Assignees
Labels
No labels