# Lazy people need to be smart

Question: Four glasses are placed on the corners of a square Lazy Susan (a square plate which can rotate about its center). Some of the glasses are upright (up) and some upside-down (down). A blindfolded person is seated next to the Lazy Susan and is required to re-arrange the glasses so that they are all … Continue reading Lazy people need to be smart

# Implement strstr

Question:  Implement strstr in Java. Find the first instance of a string in another string. . . C A P T A I N I N T E R V I E W . . Solution: public int Search(String haystack, String needle){ for(int i = 0; i < haystack.length(); i++ ) { for(int j = … Continue reading Implement strstr

# 6 Pirates Fight for 1 Gold Coin

Question: Six pirates discover a chest containing 1 gold coin. They decide to sit down and devise a distribution strategy. The pirates are ranked based on their experience (Pirate 1 to Pirate 6, where Pirate 6 is the most experienced). The most experienced pirate gets to propose a plan and then all the pirates vote … Continue reading 6 Pirates Fight for 1 Gold Coin

# 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 off every second bulb (i.e. bulb 2, 4, 6, 8 and so on). In the third round, you … Continue reading Bulb Or No Bulb?

# Red, Green and Yellow Balls

Question:  You are given two red balls, two green balls, and two yellow balls. One ball from each color is heavier than the other one. All the heavier balls weigh the same and all the lighter balls weigh the same. You are only provided with a weighing balance. How many tries would it take to … Continue reading Red, Green and Yellow Balls

# 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 … Continue reading 5 Pirates Fight for 100 Gold Coins