Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: Find the number of unique triplets (as value sets) that sum to zero in [−1, 0, 1, 2, −1, −4].

  1. A. 3
  2. B. 1
  3. C. 4
  4. D. 2

Correct answer: D. 2

Triplets are counted as distinct value multisets, so the two copies of −1 do not produce duplicates. Counting index triples gives a larger number.

More Coding Interview Problems questions

Exams that ask this topic