# Tunnel Trouble

Question: A man needs to go through a train tunnel to reach the other side. He starts running through the tunnel in an effort to reach his destination as soon as possible. When he is 1/4th of the way through the tunnel, he hears the train whistle behind him. Assuming the tunnel is not big […]

# Pick a Random Byte

Question: You have a stream of bytes from which you can read one byte at a time. You only have enough space to store one byte. After processing those bytes, you have to return a random byte. Note: The probability of picking any one of those bytes should be equal. Answer: Since we can only store […]

# 9 Minutes

Question: You are given two hourglasses. One measures 4 minutes and one measures 7 minutes. How would you measure exactly 9 minutes? Answer: This question is similar to 4 Quarts of Water. With water, we were able to fill and pour out the pail multiple times. We can use the same logic and easily come […]

# Chess Squares

Question: How many squares are on a chess board? Answer: If you thought the answer was 64, think again! How about all the squares that are formed by combining smaller squares on the chess board (2×2, 3×3, 4×4 squares and so on)? A 1×1 square can be placed on the chess board in 8 horizontal […]

# Bulb Or No Bulb?

Question: There are 100 bulbs arranged in a row. Each bulb has its own switch and is currently turned off.  In the first round, you turn every switch on. In the second round, you flip the switch of every second bulb (i.e. bulb 2, 4, 6, 8 and so on). In the third round, you […]

# How Strong is an Egg?

Question: You have two identical eggs. Standing in front of a 100 floor building, you wonder what is the maximum number of floors from which the egg can be dropped without breaking it. What is the minimum number of tries needed to find out the solution? Answer: The easiest way to do this would be […]

# Boys and Girls

Question: In a country where everyone wants a boy, each family continues having babies till they have a boy. After some time, what is the proportion of boys to girls in the country? (Assuming probability of having a boy or a girl is the same) Answer: This is a very simple probability question in a […]

# Sub-Array with the Largest Sum

Question: You are given an array with integers (both positive and negative) in any random order. Find the sub-array with the largest sum. Answer: This is an all-time favorite software interview question. The best way to solve this puzzle is to use Kadane’s algorithm which runs in O(n) time. The idea is to keep scanning […]

# How Old Are My Children?

Question: Two old friends, Jack and Bill, meet after a long time. Jack: Hey, how are you man? Bill: Not bad, got married and I have three kids now. Jack: That’s awesome. How old are they? Bill: The product of their ages is 72 and the sum of their ages is the same as your […]

# 5 Pirates Fight for 100 Gold Coins

Question: Five pirates discover a chest containing 100 gold coins. They decide to sit down and devise a distribution strategy. The pirates are ranked based on their experience (Pirate 1 to Pirate 5, where Pirate 5 is the most experienced). The most experienced pirate gets to propose a plan and then all the pirates vote […]