# Bias and Unbias

Question: Robin and Williams are playing a game. An unbiased coin is tossed repeatedly. Robin wins as soon as the sequence of tosses HHT appears. Williams wins as soon as the sequence of tosses HTH appears. The game ends when one of them wins. What are the probabilities of winning for each player? . . … Continue reading Bias and Unbias

# Life and luck

Question: You and your friend are caught by gangsters and made to play a game to determine if you should live or die. The game is simple. There is a deck of cards and you both have to choose a card. You can look at each other’s cards but not at the card you have chosen. … Continue reading Life and luck

# Chameleons go on a date

Question: On an island live 13 purple, 15 yellow and 17 maroon chameleons. When two chameleons of different colors meet, they both change into the third color. Is there a sequence of pairwise meetings after which all chameleons have the same color? . . C A P T A I N I N T E … Continue reading Chameleons go on a date

# 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

# All men must die

Question: One day, an alien comes to Earth. Every day, each alien does one of four things, each with equal probability to: (i) Kill himself (ii) Do nothing (iii) Split himself into two aliens (while killing himself) (iv) split himself into three aliens (while killing himself) What is the probability that the alien species eventually dies out … Continue reading All men must die

# 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