Register for our webinar

How to Nail your next Technical Interview

1 hour
Loading...
1
Enter details
2
Select webinar slot
*Invalid Name
*Invalid Name
By sharing your contact details, you agree to our privacy policy.
Step 1
Step 2
Congratulations!
You have registered for our webinar
check-mark
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
*All webinar slots are in the Asia/Kolkata timezone
Step 1
Step 2
check-mark
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
close-icon
Iks white logo

You may be missing out on a 66.5% salary hike*

Nick Camilleri

Head of Career Skills Development & Coaching
*Based on past data of successful IK students
Iks white logo
Help us know you better!

How many years of coding experience do you have?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Iks white logo

FREE course on 'Sorting Algorithms' by Omkar Deshpande (Stanford PhD, Head of Curriculum, IK)

Thank you! Please check your inbox for the course details.
Oops! Something went wrong while submitting the form.

Help us with your details

Oops! Something went wrong while submitting the form.
close-icon
Our June 2021 cohorts are filling up quickly. Join our free webinar to Uplevel your career
close
blog-hero-image

Top 20 Interview Puzzles for Software Engineers

by Interview Kickstart Team in Interview Questions
May 30, 2024

Top 20 Interview Puzzles for Software Engineers

Last updated by Utkarsh Sahu on May 30, 2024 at 05:59 PM | Reading time: 10 minutes

You can download a PDF version of  
Interview Puzzles for Software Engineers
Download PDF

Puzzles are a realistic way of testing your lateral thinking in software engineer interviews. It shows the interviewer your real-world problem-solving and creative thinking skills. These puzzles are mostly popular among Tier-1 companies, which look for candidates with more than basic programming skills.

All the puzzles might not have a single solution. There may be multiple solutions, and the interviewer wants to see how you find the most efficient solution and how you think through the problem.

In this article, let’s discuss some popular puzzles asked in interviews. Here’s what we’ll cover:

  • Common Puzzle Questions
  • Coding Puzzle Questions
  • Tips to Solve Puzzle Problems in Interviews
  • FAQs About Interview Puzzles for Software Engineers

Top 20 Puzzle Questions Asked in Interviews

Most of the puzzles asked in interviews are meant to test how well you can think “different.” They usually don’t have one correct answer to refer to. You can solve it using your own logic.

So, looking at 100s of puzzles online and checking their answers won’t be enough. You need to THINK on your own and actually develop an approach to solving these puzzles.

We’ve covered 20 sample puzzles to get your prep started.

Common Puzzle Questions

Common puzzles are those types of puzzles where you might not require your programming skills. It’s based on your reasoning and logical skills.

Let’s look at some common puzzles asked in interviews.

1. Crossing the Bridge Puzzle

Four people need to cross a bridge. It’s nighttime and pretty dark. There’s only one flashlight; it’s dangerous to cross the bridge without one. The bridge can only support two people at a time. Each person will take a different amount of time to cross the bridge: 1 min, 2 mins, 7 mins, and 10 mins. What is the shortest possible time for all four people to cross the bridge?

Crossing the Bridge Puzzle

2. The Man in the Elevator Puzzle

A man who lives on the tenth floor of a building takes the elevator every day to go down to the ground floor to go to work or to go shopping. When he returns in the evening, he takes the elevator to the seventh floor and walks up the stairs to the tenth floor to reach his apartment. Why does he do this? Note that if it’s a rainy day, or if there are other people in the elevator, he goes to his floor directly. Also, he hates walking.

The Man in the Elevator Puzzle

3. Heaven or Hell Puzzle

You have two doors in front of you. One door leads to heaven, and the other to hell. There are two guards, one by each door. One guard always tells the truth, and the other always lies, but you don’t know who is who. You can only ask one question to one guard to find the door to heaven. What question would you ask?

Heaven or Hell Puzzle
PrepInsta.com

4. Three Mislabeled Jars

You have three mislabeled jars. The first jar contains apples, the second contains oranges, and the third contains a mix of apples and oranges. You need to label the jars. You can pick as many fruits as you want from each jar. What is the least number of fruits you have to pick from each jar to label them correctly?

Three Mislabeled Jars
prepinsta.com

5. Gold Bar Cut Puzzle

You have hired someone to work for you for seven days, and you have a gold bar to pay him. You must give him a piece of gold every day. What is the least number of cuts you can make to the gold bar such that you can pay them 1/7th of it each day?

Gold Bar Cut Puzzle
enjoymathematics.com

6. Man Fell in Well Puzzle

A man fell in a well. The well is 30 meters deep. In a day, he can climb 4 meters, but he slips down 3 meters. How many days would he take to come out of the well?

Man Fell in Well Puzzle
tutorial.eyehunts.com

7. Bag of Coins Puzzle

You have 10 bags full of infinite coins. But one bag is full of fake coins, and you can’t remember which one. You know that a genuine coin weighs 1 gram, and a fake coin weighs 1.1 grams. How do you identify the bag containing forged coins in minimum readings?

Bag of Coins Puzzle
prepinsta.com

8. Horses on a Race Track Puzzle

There are 25 horses and five race tracks. Find the fastest three horses among the 25 in the least number of races.

Horses on a Race Track Puzzle
geeksforgeeks.org

9. Batteries Puzzle

There are eight batteries, but only four of them work. You have to use them for a flashlight, which needs two working batteries. What is the minimum number of battery pairs you need to test to ensure that the flashlight is turned on?

Batteries Puzzle
geeksforgeeks.org

10. Birthday Cake Puzzle

A birthday cake has to be cut into eight equal pieces in exactly three cuts. Find a way to make this cut possible.

Birthday Cake Puzzle
geeksforgeeks.org

11. Clock Angle Puzzle

If the time is 3:15 when you look at a clock, what’s the angle between the hour hand and the minute hand?

Clock Angle Puzzle
puzzlefry.com

12. Tomato Soup Puzzle

You have a glass of tomato soup. You have one other empty glass of a different size and shape. You have to give the soup to two children. How would you divide the soup into two glasses so that both of them are satisfied that they have got an equal share of soup?

Tomato Soup Puzzle
123rf.com

Coding Puzzle Questions

Coding Puzzles are those types of puzzles where you require a programming language to solve. Let’s look at some Coding Puzzles asked in interviews.

1. Addition Puzzle

Add two numbers without using the addition operator.

2. Determine the If Condition Puzzle

What should be the if condition in the following code snippet to print ‘Hello World’?

if "condition"
   printf ("Hello");
Else
   printf("World");

3. Swap 2 Numbers Puzzle

Swap 2 numbers without using a third variable.

4. Print Numbers From 1 to N Puzzle

Print numbers from 1 to N without using any looping construct.

5. Print Semicolon Puzzle

Print a semicolon without using a semicolon in the program

6. Equal Integers Puzzle

Determine if 2 integers are equal without using comparison and arithmetic operators.

7. Minimum Number Puzzle

Given 2 numbers. Find the minimum number without using conditional statements or ternary operators.

8. Spotting a Truck Puzzle

The probability of spotting a truck on a highway in an hour is 0.999. What is the probability of spotting a track on that highway in 20 minutes?

Head over to the Learn and Problem pages for more.

3 Key Tips to Solve Puzzle Problems in Interviews

Yes, these puzzles are tricky. Following are 3 key tips that will ensure that you will not stumble during the interview:

Tips to Solve Puzzle Problems in Interviews

1. Clarify Everything Before you Start

Don’t jump into the solution, and do not make any assumptions. If any information seems missing, ask and clarify.

2. Explain Your Process

While solving the puzzle, explain your thought process to the interviewer. It allows your interviewer to see how you plan, think, reason, and solve complex problems under pressure. Always remember — these puzzles are more about showcasing your analytical skills than finding the right solution.

3. Provide a Solution to the Puzzle — One or More!

Use your reasoning and logical skills to deduce a solution to the puzzle, even if it’s not the correct solution. You can also discuss alternate methods. It’s more about your reasoning and deducing the solution, than finding the right solution.

FAQs on Puzzles for Software Engineers

Q. Do we get asked only programming puzzles in interviews?

A. No. Interviewers test your ability to answer programming as well as common puzzles, which don't require programming skills.

Q. How to prepare for puzzle questions for an interview?

A. Practice multiple puzzles online, and try to solve them on your own without looking for answers. Interviewers will test your thinking abilities and insist more than getting the correct answer.

Q. Are puzzle interviews effective for employee selection?

A. Some of these calculations require significant approximations and come with unclear instructions regarding constraints. Due to their unconnected skill concentration, potential prejudice, and inability to accurately predict work performance, puzzle interviews are typically ineffective in the selection of employees.

Q. How many rounds of interviews do software engineers have?

A. There are generally four to five rounds of interviews for senior roles.

Preparing for a Tech Interview?

Interview Kickstart can help you with coding puzzles and more! With IK, you get the unique opportunity to learn from and engage with FAANG tech leads and hiring managers.

Here’s what Aliya Mussina, IK alum and Software Engineer at Apple, has to say about IK’s program:
Interview Kickstart's Program Met All My Expectations.

Want to know more? Sign up for our FREE webinar.


Author
Utkarsh Sahu
Director, Category Management @ Interview Kickstart || IIM Bangalore || NITW.
The fast well prepared banner

Puzzles are a realistic way of testing your lateral thinking in software engineer interviews. It shows the interviewer your real-world problem-solving and creative thinking skills. These puzzles are mostly popular among Tier-1 companies, which look for candidates with more than basic programming skills.

All the puzzles might not have a single solution. There may be multiple solutions, and the interviewer wants to see how you find the most efficient solution and how you think through the problem.

In this article, let’s discuss some popular puzzles asked in interviews. Here’s what we’ll cover:

  • Common Puzzle Questions
  • Coding Puzzle Questions
  • Tips to Solve Puzzle Problems in Interviews
  • FAQs About Interview Puzzles for Software Engineers

Top 20 Puzzle Questions Asked in Interviews

Most of the puzzles asked in interviews are meant to test how well you can think “different.” They usually don’t have one correct answer to refer to. You can solve it using your own logic.

So, looking at 100s of puzzles online and checking their answers won’t be enough. You need to THINK on your own and actually develop an approach to solving these puzzles.

We’ve covered 20 sample puzzles to get your prep started.

Common Puzzle Questions

Common puzzles are those types of puzzles where you might not require your programming skills. It’s based on your reasoning and logical skills.

Let’s look at some common puzzles asked in interviews.

1. Crossing the Bridge Puzzle

Four people need to cross a bridge. It’s nighttime and pretty dark. There’s only one flashlight; it’s dangerous to cross the bridge without one. The bridge can only support two people at a time. Each person will take a different amount of time to cross the bridge: 1 min, 2 mins, 7 mins, and 10 mins. What is the shortest possible time for all four people to cross the bridge?

Crossing the Bridge Puzzle

2. The Man in the Elevator Puzzle

A man who lives on the tenth floor of a building takes the elevator every day to go down to the ground floor to go to work or to go shopping. When he returns in the evening, he takes the elevator to the seventh floor and walks up the stairs to the tenth floor to reach his apartment. Why does he do this? Note that if it’s a rainy day, or if there are other people in the elevator, he goes to his floor directly. Also, he hates walking.

The Man in the Elevator Puzzle

3. Heaven or Hell Puzzle

You have two doors in front of you. One door leads to heaven, and the other to hell. There are two guards, one by each door. One guard always tells the truth, and the other always lies, but you don’t know who is who. You can only ask one question to one guard to find the door to heaven. What question would you ask?

Heaven or Hell Puzzle
PrepInsta.com

4. Three Mislabeled Jars

You have three mislabeled jars. The first jar contains apples, the second contains oranges, and the third contains a mix of apples and oranges. You need to label the jars. You can pick as many fruits as you want from each jar. What is the least number of fruits you have to pick from each jar to label them correctly?

Three Mislabeled Jars
prepinsta.com

5. Gold Bar Cut Puzzle

You have hired someone to work for you for seven days, and you have a gold bar to pay him. You must give him a piece of gold every day. What is the least number of cuts you can make to the gold bar such that you can pay them 1/7th of it each day?

Gold Bar Cut Puzzle
enjoymathematics.com

6. Man Fell in Well Puzzle

A man fell in a well. The well is 30 meters deep. In a day, he can climb 4 meters, but he slips down 3 meters. How many days would he take to come out of the well?

Man Fell in Well Puzzle
tutorial.eyehunts.com

7. Bag of Coins Puzzle

You have 10 bags full of infinite coins. But one bag is full of fake coins, and you can’t remember which one. You know that a genuine coin weighs 1 gram, and a fake coin weighs 1.1 grams. How do you identify the bag containing forged coins in minimum readings?

Bag of Coins Puzzle
prepinsta.com

8. Horses on a Race Track Puzzle

There are 25 horses and five race tracks. Find the fastest three horses among the 25 in the least number of races.

Horses on a Race Track Puzzle
geeksforgeeks.org

9. Batteries Puzzle

There are eight batteries, but only four of them work. You have to use them for a flashlight, which needs two working batteries. What is the minimum number of battery pairs you need to test to ensure that the flashlight is turned on?

Batteries Puzzle
geeksforgeeks.org

10. Birthday Cake Puzzle

A birthday cake has to be cut into eight equal pieces in exactly three cuts. Find a way to make this cut possible.

Birthday Cake Puzzle
geeksforgeeks.org

11. Clock Angle Puzzle

If the time is 3:15 when you look at a clock, what’s the angle between the hour hand and the minute hand?

Clock Angle Puzzle
puzzlefry.com

12. Tomato Soup Puzzle

You have a glass of tomato soup. You have one other empty glass of a different size and shape. You have to give the soup to two children. How would you divide the soup into two glasses so that both of them are satisfied that they have got an equal share of soup?

Tomato Soup Puzzle
123rf.com

Coding Puzzle Questions

Coding Puzzles are those types of puzzles where you require a programming language to solve. Let’s look at some Coding Puzzles asked in interviews.

1. Addition Puzzle

Add two numbers without using the addition operator.

2. Determine the If Condition Puzzle

What should be the if condition in the following code snippet to print ‘Hello World’?

if "condition"
   printf ("Hello");
Else
   printf("World");

3. Swap 2 Numbers Puzzle

Swap 2 numbers without using a third variable.

4. Print Numbers From 1 to N Puzzle

Print numbers from 1 to N without using any looping construct.

5. Print Semicolon Puzzle

Print a semicolon without using a semicolon in the program

6. Equal Integers Puzzle

Determine if 2 integers are equal without using comparison and arithmetic operators.

7. Minimum Number Puzzle

Given 2 numbers. Find the minimum number without using conditional statements or ternary operators.

8. Spotting a Truck Puzzle

The probability of spotting a truck on a highway in an hour is 0.999. What is the probability of spotting a track on that highway in 20 minutes?

Head over to the Learn and Problem pages for more.

3 Key Tips to Solve Puzzle Problems in Interviews

Yes, these puzzles are tricky. Following are 3 key tips that will ensure that you will not stumble during the interview:

Tips to Solve Puzzle Problems in Interviews

1. Clarify Everything Before you Start

Don’t jump into the solution, and do not make any assumptions. If any information seems missing, ask and clarify.

2. Explain Your Process

While solving the puzzle, explain your thought process to the interviewer. It allows your interviewer to see how you plan, think, reason, and solve complex problems under pressure. Always remember — these puzzles are more about showcasing your analytical skills than finding the right solution.

3. Provide a Solution to the Puzzle — One or More!

Use your reasoning and logical skills to deduce a solution to the puzzle, even if it’s not the correct solution. You can also discuss alternate methods. It’s more about your reasoning and deducing the solution, than finding the right solution.

FAQs on Puzzles for Software Engineers

Q. Do we get asked only programming puzzles in interviews?

A. No. Interviewers test your ability to answer programming as well as common puzzles, which don't require programming skills.

Q. How to prepare for puzzle questions for an interview?

A. Practice multiple puzzles online, and try to solve them on your own without looking for answers. Interviewers will test your thinking abilities and insist more than getting the correct answer.

Q. Are puzzle interviews effective for employee selection?

A. Some of these calculations require significant approximations and come with unclear instructions regarding constraints. Due to their unconnected skill concentration, potential prejudice, and inability to accurately predict work performance, puzzle interviews are typically ineffective in the selection of employees.

Q. How many rounds of interviews do software engineers have?

A. There are generally four to five rounds of interviews for senior roles.

Preparing for a Tech Interview?

Interview Kickstart can help you with coding puzzles and more! With IK, you get the unique opportunity to learn from and engage with FAANG tech leads and hiring managers.

Here’s what Aliya Mussina, IK alum and Software Engineer at Apple, has to say about IK’s program:
Interview Kickstart's Program Met All My Expectations.

Want to know more? Sign up for our FREE webinar.


Recession-proof your Career

Recession-proof your Software Engineering Career

Attend our free webinar to amp up your career and get the salary you deserve.

Ryan-image
Hosted By
Ryan Valles
Founder, Interview Kickstart
blue tick
Accelerate your Interview prep with Tier-1 tech instructors
blue tick
360° courses that have helped 14,000+ tech professionals
blue tick
57% average salary hike received by alums in 2022
blue tick
100% money-back guarantee*
Register for Webinar

Recession-proof your Career

Recession-proof your Software Engineering Career

Attend our free webinar to amp up your career and get the salary you deserve.

Ryan-image
Hosted By
Ryan Valles
Founder, Interview Kickstart
blue tick
Accelerate your Interview prep with Tier-1 tech instructors
blue tick
360° courses that have helped 14,000+ tech professionals
blue tick
57% average salary hike received by alums in 2022
blue tick
100% money-back guarantee*
Register for Webinar

Attend our Free Webinar on How to Nail Your Next Technical Interview

Register for our webinar

How to Nail your next Technical Interview

1
Enter details
2
Select webinar slot
By sharing your contact details, you agree to our privacy policy.
Step 1
Step 2
Congratulations!
You have registered for our webinar
check-mark
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
Step 1
Step 2
check-mark
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
All Blog Posts
entroll-image
closeAbout usWhy usInstructorsReviewsCostFAQContactBlogRegister for Webinar