Top 20 - Interview Puzzles For Software Engineers: Top 20 Puzzle Questions Asked in Interviews
Top 20 - Interview Puzzles For Software Engineers: Top 20 Puzzle Questions Asked in Interviews
Top 20 - Interview Puzzles For Software Engineers: Top 20 Puzzle Questions Asked in Interviews
Software Engineers
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.
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.
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?
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.
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?
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?
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?
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?
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?
There are 25 horses and five race tracks. Find the fastest three horses among the 25 in
the least number of races.
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?
A birthday cake has to be cut into eight equal pieces in exactly three cuts. Find a way to
make this cut possible.
If the time is 3:15 when you look at a clock, what’s the angle between the hour hand and
the minute hand?
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?
1. Addition Puzzle
What should be the if condition in the following code snippet to print ‘Hello World’?
Else
printf("World");
Determine if 2 integers are equal without using comparison and arithmetic operators.
Given 2 numbers. Find the minimum number without using conditional statements or
ternary operators.
Don’t jump into the solution, and do not make any assumptions. If any information
seems missing, ask and clarify.
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.
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.