Mick and John were in a 100 meter race. When Mick crossed the finish line, John was only at the 90 meter mark. Mick suggested they run another race. This time, Mick would start ten meters behind the starting line. All other things being equal, will John win, lose, or will it be a tie in the second race?
John will lose again. In the second race, Mick started ten meters back. By the time John reaches the 90 meter mark, Mick will have caught up him. Therefore, the final ten meters will belong to the faster of the two. Since Mick is faster than John, he will win the final 10 meters and of course the race.
Two words are anagrams if and only if they contain the exact same letters with the exact same frequency (for example, "name" and "mean" are anagrams, but "red" and "deer" are not).
Given two strings S1 and S2, which each only contain the lowercase letters a through z, write a program to determine if S1 and S2 are anagrams. The program must have a running time of O(n + m), where n and m are the lengths of S1 and S2, respectively, and it must have O(1) (constant) space usage.
First create an array A of length 26, representing the counts of each letter of the alphabet, with each value initialized to 0. Iterate through each character in S1 and add 1 to the corresponding entry in A. Once this iteration is complete, A will contain the counts for the letters in S1. Then, iterate through each character in S2, and subtract 1 from each corresponding entry in A. Now, if the each entry in A is 0, then S1 and S2 are anagrams; otherwise, S1 and S2 aren't anagrams.
Here is pseudocode for the procedure that was described:
def areAnagrams(S1, S2)
A = new Array(26)
for each character in S1
arrayIndex = mapCharacterToNumber(character) //maps "a" to 0, "b" to 1, "c" to 2, etc...
A[arrayIndex] += 1
for each character in S2
arrayIndex = mapCharacterToNumber(character)
A[arrayIndex] -= 1
for (i = 0; i < 26; i++)
if A[i] != 0
This teaser is based on a weird but true story from a few years ago. A complaint was received by the president of a major car company: "This is the fourth time I have written you, and I don't blame you for not answering me because I must sound crazy, but it is a fact that we have a tradition in our family of having ice cream for dessert after dinner each night. Every night after we've eaten, the family votes on which flavor of ice cream we should have and I drive down to the store to get it. I recently purchased a new Pantsmobile from your company and since then my trips to the store have created a problem. You see, every time I buy vanilla ice cream my car won't start. If I get any other kind of ice cream the car starts just fine. I want you to know I'm serious about this question, no matter how silly it sounds: 'What is there about a Pantsmobile that makes it not start when I get vanilla ice cream, and easy to start whenever I get any other kind?'"
The Pantsmobile company President was understandably skeptical about the letter, but he sent an engineer to check it out anyway. He had arranged to meet the man just after dinner time, so the two hopped into the car and drove to the grocery store. The man bought vanilla ice cream that night and, sure enough, after they came back to the car it wouldn't start for several minutes. The engineer returned for three more nights. The first night, the man got chocolate. The car started right away. The second night, he got strawberry and again the car started right up. The third night he bought vanilla and the car failed to start. There was a logical reason why the man's car wouldn't start when he bought vanilla ice cream. What was it?
The man lived in an extremely hot city, and this took place during the summer. Also, the layout of the grocery store was such that it took the man less time to buy vanilla ice cream.
Vanilla ice cream was the most popular flavor and was on display in a little case near the express check out, while the other flavors were in the back of the store and took more time to select and check out. This mattered because the man's car was experiencing vapor lock, which is excess heat boiling the fuel in the fuel line and the resulting air bubbles blocking the flow of fuel until the car has enough time to cool.. When the car was running there was enough pressure to move the bubbles along, but not when the car was trying to start.
Romeo and Juliet are found dead on the floor in a bedroom. When they were discovered, there were pieces of glass and some water on the floor. The only furniture in the room is a shelf and a bed. The house is in a remote location, away from everything except for the nearby railroad track. What caused the death of Romeo and Juliet?
Romeo and Juliet are fishies. The rumble of the train knocked the tank off the shelf, it broke and Romeo and Julia did not survive.
You are on a gameshow and the host shows you three doors. Behind one door is a suitcase with $1 million in it, and behind the other two doors are sacks of coal. The host tells you to choose a door, and that the prize behind that door will be yours to keep.
You point to one of the three doors. The host says, "Before we open the door you pointed to, I am going to open one of the other doors." He points to one of the other doors, and it swings open, revealing a sack of coal behind it.
"Now I will give you a choice," the host tells you. "You can either stick with the door you originally chose, or you can choose to switch to the other unopened door."
Should you switch doors, stick with your original choice, or does it not matter?
You should switch doors.
There are 3 possibilities for the first door you picked:
You picked the first wrong door - so if you switch, you win
You picked the other wrong door - again, if you switch, you win
You picked the correct door - if you switch, you lose
Each of these cases are equally likely. So if you switch, there is a 2/3 chance that you will win (because there is a 2/3 chance that you are in one of the first two cases listed above), and a 1/3 chance you'll lose. So switching is a good idea.
Another way to look at this is to imagine that you're on a similar game show, except with 100 doors. 99 of those doors have coal behind them, 1 has the money. The host tells you to pick a door, and you point to one, knowing almost certainly that you did not pick the correct one (there's only a 1 in 100 chance). Then the host opens 98 other doors, leave only the door you picked and one other door closed. We know that the host was forced to leave the door with money behind it closed, so it is almost definitely the door we did not pick initially, and we would be wise to switch.
Search: Monty Hall problem
A young woman is attending her mother's funeral. While there, she meets a man she has never seen before and falls in love immediately. After the funeral she tries to find him but cannot. Several days later she kills her sister. Why does she kill her sister?
She killed her sister hoping to see this man at her sisters funeral.
Note: If you thought of this answer easily you may be a psychopath