Skip to main content
All Questions

Count the handshakes among N people when nobody shakes hands with their own team.

Unlock detailed company stats for this questionUpgrade

At a company event, N people are in a room. Each person shakes hands with every other person exactly once, except that people do not shake hands with members of their own team. Given the total number of people N and an array of team sizes, find the total number of handshakes. Examples: N = 4, teams = [2, 2]; N = 7, teams = [1, 3, 3].

Format · Technical interview.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.