Trains the technique from
LeetCode 153SumThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A physics teaching kit holds a tray of numbered beads. charges[i] is the electric charge carried by bead i, measured in elementary units, and it may be positive, negative or zero.
A neutral triple is a set of three beads sitting at three different positions in the tray whose charges add to zero.
Report the charge values of every neutral triple the tray allows. Ordering is irrelevant: the three values within a triple may be listed in any order, and the triples themselves may be listed in any order.
A combination of charge values may only be reported once. Beads at different positions can carry equal charges, and many bead sets can therefore land on the same three values, but they all describe one triple in your answer. A single bead may not fill two of the three slots of a triple.
Example 1
Three combinations settle to zero. The last one draws on both beads carrying -1, which is allowed because they sit at separate positions.
Example 2
Four beads can be picked three at a time in four ways, yet every pick lands on the same three charge values, so the answer holds one triple.
Example 3
The only available set of three beads carries a total of 7, so nothing is reported.
The groups you return, and the values inside each group, may be in any order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def charge_neutral_triples(charges: list[int]) -> list[list[int]]:public List<List<Integer>> chargeNeutralTriples(int[] charges)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.