Browsing the archives for the numbers tag

The Fox and The Duck

Question: A duck that is being chased by a fox saves itself by sitting at the center of circular pond of radius r. The duck can fly from land but cannot fly from the water. Furthermore, the fox cannot swim. The fox is four times faster than the duck. Assuming that the duck and fox […]

2 Comments

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 […]

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 […]

2 Comments

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 […]

81 Comments

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 […]

22 Comments

Trailing Zeros in 100 Factorial

Question: How many¬†zeros¬†are there in 100! (100 factorial)? Answer: For those who don’t know what factorial is, 100! = 100 * 99 * 98 * … * 2 * 1 Ok, let’s look at how trailing zeros are formed in the first place. A trailing zero is formed when a multiple of 5 is multiplied […]

1 Comment