Skip to content
← Back to the archive

13 September 2026 · Advanced track

Warehouse Load Balancing Triplets

Advanced Lists Numbers

Count how many distinct triplets of crate weights add up to a target load.

A loading dock has a list of crate weights waiting to be grouped into three-crate pallets, and a target pallet weight. Consider every way of choosing three different positions in the list, regardless of order. A group matches whenever the three weights at those positions add up to exactly the target. Return the total number of matching groups. Two matching groups that select the exact same three weight values only count as one - report the number of distinct weight-value combinations that match, not the number of different positions that could produce them.

Constraints

  • weights has between 0 and 500 entries
  • each weight is a whole number between -1000000 and 1000000
  • target is a whole number between -3000000 and 3000000
  • a group must use three different positions from the list

Function signature

def count_target_sum_triplets(weights, target):

Sign in to solve this bracket

Reading the problem is free for everyone. Opening the editor and solving it requires an account with Open Bracket+.