Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

triplets =
target =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Only keep triplets that don't exceed target; we need to hit each target coordinate.

Approach

Scan triplets. If a triplet is component-wise <= target, it’s eligible. Track whether we’ve seen an eligible triplet matching tx, ty, tz in each coordinate. Return true if all three coordinates can be matched.

Why it works

Merging uses component-wise max, so any value exceeding target can never be used; and achieving target requires some chosen triplet(s) contributing each exact coordinate.

Code
Loading...
Complexity
Time: O(n)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Only keep triplets that don't exceed target; we need to hit each target coordinate.

Approach

Scan triplets. If a triplet is component-wise <= target, it’s eligible. Track whether we’ve seen an eligible triplet matching tx, ty, tz in each coordinate. Return true if all three coordinates can be matched.

Why it works

Merging uses component-wise max, so any value exceeding target can never be used; and achieving target requires some chosen triplet(s) contributing each exact coordinate.

Code
Loading...
Complexity
Time: O(n)
Space: O(1)