A site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!
There is a pot of N noodles. (so there are 2N ends). A person randomly grabs two ends and merges them. The person keeps doing it, until there are no more noodles, (and only loops), left in the pot. what’s the average number of loops in the pot?
A person dies, and arrives at the gate to heaven. there are three doors. one of them leads to heaven. another one leads to a 1-day stay at hell, and then back to the gate, and the other leads to a 2-day stay at hell, and then back to the gate. every time the person is back at the gate, the three doors are reshuffled. How long will it take the person to reach heaven?
Someone walks into your room and dumps a huge bag of quarters all over the floor. They spread them out so no quarters are on top of any other quarters. a robot then comes into the room and is programmed such that if it sees a head, it flips it to tails. If it sees a tail, it throws it in the air. the robot moves around randomly forever. Will there be a convergence in distribution of heads vs. tails?
I challenge you to a game. we each get one penny and we flip them at the same time. (so on turn 1, we each flip our respective pennies – turn 2, we flip them again, and so on until someone wins). I am looking to get heads then tails. You are looking to get heads then heads. So if you flip heads on any flip and then heads on the next flip, you win. If I flip heads on any flip and then tails on the next flip, I win. (its not a speed race, we both flip at the same time, except i’m only concerned with what appears on my coin, and you are only concerned with whats on your coin). Are the odds fair? (obviously not, otherwise this wouldn’t be a question). who has the advantage and why?
How does one find a loop in a singly linked list in O(n) time using constant memory? You cannot modify the list in any way (and constant memory means the amount of memory required for the solution cannot be a function of n.).
You have 20 blue balls and 14 red balls in a bag. you put your hand in and remove 2 at a time. If they’re of the same color, you add a blue ball to the bag. If they’re of different colors, you add a red ball to the bag. (assume you have a big supply of blue & red balls for this purpose. note: when you take the two balls out, you don’t put them back in, so the number of balls in the bag keeps decreasing). What will be the color of the last ball left in the bag?
Every night, I dump all the change in my pocket into a big bucket.
When I buy things, I never hand over coins. always bills. So I accumulate a lot of coins. Even if the purchase price is $1.01, and I have lots of coins in my pocket, I pay $2 and take the 99 cents in change. All the more coins to dump in my change bucket!
A man has two cubes on his desk. every day he arranges both cubes so that the front faces show the current day of the month. what numbers are on the faces of the cubes to allow this?
First, to show all possible days, we’d need one of each of the ten digits. We’d also need two 1s and two 2s to show 11 and 22. That’s twelve numbers right there. Two cubes, twelve faces, so every face is used. Quite elegant.
In a country in which people only want boys, every family continues to have children until they have a boy. if they have a girl, they have another child. if they have a boy, they stop. what is the proportion of boys to girls in the country?
I flip a penny and a dime and hide the result from you. “one of the coins came up heads”, i announce. what is the chance that the other coin also came up heads?
Assuming complete honesty on the part of the flipper, wouldn’t the solution be 33%?