Browsing the archives for the easy tag

Globe Walker

Question: How many points are there on the globe where, by walking one mile south, then one mile east and then one mile north, you would reach the place where you started? Answer: The trivial answer to this question is one point, namely, the North Pole. But if you think that answer should suffice, you […]

4 Comments

Clock Hands

Question: How many times a day do the minute and hour hands of a clock overlap? Answer: Did you think the answer was 24 times? Well if you did, it’s time you think again. Let’s do some math. In T hours, the minute hand completes T laps. In the same amount of time, the hour hand […]

21 Comments

10 Google Interview Puzzles

Here is a list of 10 puzzles which have been asked on a Google Interview. They are not in any specific order. Reverse a Linked-List Reverse a Linked-list. Write code in C. Answer Challenge – Equal Probability between 1 and 7 Write a method to generate a random number between 1 and 7, given a […]

The Ant Problem

Question: Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction and starts to move along the edge of the triangle. What is the probability that none of the ants collide? Answer: So let’s think this through. The ants can only avoid a collision if they […]

13 Comments

Piece of Cake

Question: How would you cut a rectangular cake into two equal pieces when a rectangular piece has already been cut out of it? The cut piece can be of any size and orientation. You are only allowed to make one straight cut. Answer: Simple question right? There are two possible solutions to this problem. People […]

19 Comments

Combinations of a String

Question: Write an algorithm to print all possible combinations of characters in a string. Answer: Any thoughts? One thing is for sure, we can definitely use some recursive logic here. Let’s approach this problem methodically. Since we need to generate combinations, we can start with a single character and then continue to add a character […]

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

First Non-Repeated Character

Question: Write an algorithm to find the first non-repeated character in a string. For example, the first non-repeated character in the string ‘abcdab’ is ‘c’. Answer: Seems trivial enough right? If a character is repeated, we should be able to search the string to determine if that character appears again. So if we go about […]

Number of Ones

Question: Write a function that determines the number of bits set to 1 in the binary representation of an integer. Answer: Going by the brute force approach, it would be easy to come up with the following solution. If the least significant bit of a number is 1, it will return a result of 1 […]

Farmer’s Dilemma

Question: A farmer bought a goat, a wolf and a cabbage from the market. On his way home, he has to cross a river. He has a small boat which only allows him to take one thing with him at a time. The farmer cannot leave the cabbage and the goat together (the goat would […]

2 Comments