mediumGreedyAmazon
Target Triple Composer
A sculpting robot picks any triplets whose coords ≤ target, taking element-wise max; can it hit the exact target triplet?
Given a list of triplets and a target triplet, decide if element-wise maximums of a chosen subset can equal target. Triplets whose any component exceeds target are useless.
Choose approach
2
07
15
2Setfound
0:✓
1:·
2:·
1/4
Narrationstep 1 of 4
Triplet [2,5,3] accepted. found=[true,false,false].
Variables
r=0
found=true,false,false
rejected=false
How to think about it
- Max is monotone -> any valid-size triplet is safe to use.
- Need at least one triplet to supply each coordinate's target.
Edge cases to catch in interview
- No valid triplets -> false.
- Target already appears as a triplet -> true.
Examples
Example 1
false{"triplets":[[3,4,2],[4,2,4],[3,3,2]],"target":[3,2,5],"values":[3,2,5]}
Try your own input
SpacePlay / pause
← / →Previous / next step
RReset to start
. or >Cycle speed