triples and a target triple goal.
In one operation you pick two different triples at indices i and j and replace triple j with the element-wise maximum of the two. For example, [2, 5, 3] and [1, 7, 5] turn the second one into [2, 7, 5].
You may perform any number of operations, including none. Return True if goal can end up as one of the triples in the list, and False otherwise.triples=[[4, 1, 2], [1, 6, 3], [2, 3, 9], [3, 5, 1]], goal=[4, 6, 3] → True
Merging [4, 1, 2] with [1, 6, 3] gives [4, 6, 3]. The triple [2, 3, 9] must stay out because 9 exceeds 3.
triples=[[2, 2, 7], [5, 1, 1]], goal=[5, 2, 5] → False
No usable triple has 5 in the last position: [2, 2, 7] has 7, which is too big, and [5, 1, 1] has only 1. It cannot be built.
triples=[[8, 8, 8]], goal=[8, 8, 8] → True
goal, has exactly three numberstriples=[[4, 1, 2], [1, 6, 3], [2, 3, 9], [3, 5, 1]], goal=[4, 6, 3]
True
Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.