Find All Distinct Triples of Reaction Deltas Summing to Zero

Last updated: November 29, 2026

Quick Overview

Given an array of signed daily reaction-count deltas, return every distinct triple of values that sums to zero, with no duplicate triples in the output.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given an array of signed daily reaction-count deltas, return every distinct triple of values that sums to zero, with no duplicate triples in the output.

A standard Meta onsite coding problem, here dressed as reconciling reaction deltas that should cancel out. The interviewer cares most about duplicate handling and a clean sort plus two pointer loop under time pressure.

What the Interviewer Expects
  • Sorts first and fixes one element, then runs two pointers on the rest
  • Skips duplicate anchors and duplicate pointer values to avoid repeated triples
  • Breaks early when the anchor is positive
  • States O(n^2) time and why that is the practical lower bound here
  • Tests an input with many zeros and repeated values
Key Topics to Cover
two pointers
sorting
3sum
deduplication
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return the count of index triples instead of distinct value triples.
  • Generalize to k values summing to a target.
  • What if the array is too large for memory but values lie in a small range?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: deltas, a list of integers, length up to a few thousand. Output: a list of triples [a, b, c] with a <= b <= c and a + b + c == 0, each distinct value triple appearing once. Order of tri...

High-Level Design

Sort the array. For each index i as the smallest element, skip it if it equals the previous anchor. Then set lo = i+1, hi = n-1, and move them by the sign of the sum: too small moves lo right,...


Submit Your Answer
Markdown supported