Calculating Group Average Salary Anonymously

Finding average salary without revealing salaries is an easy quant interview question on Brain Teasers.

Difficulty Easy Topic Brain Teasers

This brain teaser describes a small group of people who all want to compute the group's average salary without revealing any individual salary to anyone else. The setup is framed as an informal gathering, but the underlying problem is a stylized version of secure multi-party computation: how to perform a simple aggregate calculation while preserving the privacy of each input. It is a common style of puzzle in quantitative and tech interviews, especially when an interviewer wants to test whether a candidate can recognize and structure a protocol rather than just crunch numbers.

The solution approach leans on commutative and associative operations, random masking, and careful control of what partial information is exposed at each step. The interviewer is looking for an answer that maintains strict privacy even in edge cases, not just "nobody obviously sees the others' numbers." Strong answers show awareness of how randomness hides intermediate values, how and when masks can be removed, and how the protocol scales to more participants. Clarity in describing the sequence of actions and reasoning about information leakage is often more important than the specific narrative details.

What it tests

The core structure in problems of this class is information aggregation with privacy preservation, often achieved through the use of commutative operations and random masking. The key is that each participant can contribute their data in a way that, when all contributions are combined, the aggregate is revealed but no individual component is exposed. This is possible because operations like addition are commutative and associative, and because random numbers (or masks) can be added and later subtracted without altering the final sum. The random mask ensures that intermediate results are meaningless to observers, and only the final step, where the mask is removed, reveals the true aggregate. This principle enables group computations where privacy is essential, such as secure multi-party summation or distributed data analysis.

Practise this question with written feedback, or hear it in a spoken mock interview.

Get started free