Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
Problem Statement
Frequently Asked Questions
What are interview puzzles?
How to answer puzzle interview questions?
What are some types of interview puzzles?
What are some tips for preparing for a puzzle interview?
Name some common puzzles asked in the interview.
Last Updated: Mar 27, 2024

Dinner Hand Shakes

Author Komal Shaw
0 upvote
Master Python: Predicting weather forecasts
Ashwin Goyal
Product Manager @
Interview Puzzles


Puzzles are made to get the brain into a thinking space and turn the gears. They help sharpen analytical skills and develop cognitive ability.

These types of questions are often asked in Interviews. So, we will be going through the problem statement and then analyzing it to get a better understanding.

Problem Statement

A couple invites n - 1 other couple to dinner.

Once everyone arrives, each person shakes hands with everyone he doesn't know.

Then, the host asked everyone how many hands they shook, and each person replied with a different number. Assuming everyone knows their spouse, how many hands did the hostess shake?

Select your answer from the following options:

  • 0
  • N - 1
  • 2*N - 1
  • Indeterministic
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job


A person shook no hands, and another person shook hands with everyone else from the other couples. It's possible only when these two people are a married couple. 

A person shook only 2N-2 hands, and another person shook hands with everyone else from all the other couples except person 0. So these two people also need to be married.

In the same way, we will pair up all the couples leaving the party's hosts. From that pair, one person will be the shook-no-hands-not-already-mentioned person(refers to the person who has not shaken any hands with a person not mentioned earlier), and the other will be the shook-all-hands-not-already-mentioned person(refers to the person who has already shaken hands with a person who was not already mentioned). Thus the last must have been shaken N-2 and N hands, respectively.

From the above, we understand that the party's hostess has to shake N-1 hands. (Both the host and the hostess shake hands with exactly one member of each couple. Thus each will shake N-1 people's hands).

illustration image


Let's take an example. Say n = 6. This implies that there are 5 couples invited to the party(the other couple is the host of the party). Out of the total 6 couples, no one is shaking more than 10 hands. The person who will be shaking 10 hands needs to be married to a person who shook 0 hands. In the same way, the person who shook 9 hands needs to be married to the person who shook 1 hand. Thus the logic continues and the person who shook 5 hands is the host.

Thus the answer is N-1.
Check out this problem - 8 Queens Problem

Frequently Asked Questions

What are interview puzzles?

Interview puzzles are some critical thinking problems or brain teasers.

How to answer puzzle interview questions?

We need to first think about the problem, then ask for clarification, use whatever resources we have, explain our reasoning, and provide the solution.

What are some types of interview puzzles?

Riddles and questions, finding amounts, and number tricks.

What are some tips for preparing for a puzzle interview?

Practice, always keep a pen and paper with you and elaborate your approach.

Name some common puzzles asked in the interview.

Crossing the bridge, Hand Shakes at the party, Bag of coins, Clock angle puzzle, Measuring time by burning ropes, and many more.


In this article, we have extensively discussed the approach for the "Dinner hand Shakes" Puzzle Problem. We hope that this blog has helped you understand the process. 

Logical Puzzles:

Pattern Based Puzzles:

Recommended Readings:

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Interview Puzzles, Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Happy Coding!

Previous article
Measuring Time by Burning Ropes
Next article
Color of the Last Ball II
Live masterclass