Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Sunday, July 4, 2010

Amoeba population

A jar begins with one amoeba.Every minute , every amoeba turns into  0 ,1,2 or 3 with 25% probability for each case (dies, does nothing,splits into 2 , splits into 3).What is the probability that amoeba population eventually dies out?

Saturday, March 20, 2010

Interview Questions: Flipkart

Flipkart Interview Questions

1) Linked List reversal , without using any extra memory. (Code Insertion)

2) M 0's N 1's M>N. No. of possible permutations of String of length M+N.

3) Count no of characters/words/lines in a file. Given file handle definition.

4) Merge two trees into a new tree.
Example: (1,(2,null))and (1,(null,3)) results in (1,(2,3))
(1,(2,null))and (1,(3,null)) results in null (Not a valid operation)

5) Consider linked list {1,2,3,4,5,6}
return {2,1,4,3,6,5}. Write a function that does this without using any extra memory.

6) func(){
fork();
fork();
fork();
print("Saikacollection\n");
}
Output = ?

7) Suppose process process p1 creates a child process p2. If p1 gets killed then what happens to p2?

8) Output?
sum = 0;
for(int i = 0;i<12;i++){ j =" i+1;j<10;j++){" k =" j+1;k">8;k++){
sum++;
}
}
}
printf("%d",sum);

9) Monty Hall Problem Card variant.


10) Simple probability question. 6 Organges and 4 Apples. prob of Picking two oranges?


Thanks to chirag for this post.

Thursday, February 25, 2010

Hungry Elephant


This one is easy and most famous puzzle.
But I have a doubt here which I would post later after getting answers .

There are 2 cities A and B, distance between them is 1000 Km.
we have 3000 bananas in city A and a elephant
can carry max 1000 bananas at any given time and it needs to eat a banana every 1 Km.

How Many Max. No. of bananas you can transfer to city B ?.

Wednesday, February 24, 2010

Boat and Dock


You are Sitting in a small boat holding the end of a rope.The other end of the rope is tied to the top of
a nearby pier (See figure) , such that the it is higher above the water than your end of the rope,Causing your boat to move towards the pier,stopping directly underneath the pier.As you pull on the rope, which is moving faster :boat or the rope?
i.e the speed of the boat moves across the water or the speed the rope moves through your hands.

Looks like difficult one but not exactly.

Tuesday, February 23, 2010

PJ Puzzle


In which direction is the bus moving?
Right or Left?

Monday, February 22, 2010

Blind Man and Cards


A blind man is handed a deck of 52 cards and told that exactly 10 of these cards are facing up. How can he divide the cards into two piles, not necessarily of equal size, with each pile having the same number of cards facing up?

Tuesday, February 16, 2010

How will you measure?

You are given 2 containers one is of 5 liters capacity and other is 3 liters.
Measure 4 liters using the above two containers only.(You are given unlimited supply of water , containers are unmarked).


Start from the 5 liters can fill it and empty it in to 3 liters.
So now you have 2 liters in 5 liter can and 3 liters can is full.
Empty 3 liters can . And move 2 liters from 5 liter can to 3 liter can.
Now 3 liter can has 2 liters and 5 liter can is empty.
Now Again fill 5 liter can . Transfer as much as you can in 3 liters can.
Since you are left with only 1 liter volume in 3 liter can you can transfer only 1 liter into it.So you are left with 4 liters in 5 liters can now.

50-> 23 -> 20 -> 02 -> 52 -> 43.


Mathematically

5x+3y = 4
x = 2 y =-2 Therefore |x| + |y| = 4

i.e we need to find x and y values such that |x|+|y| is minimum.

So x here means take water 2 times from 5 liter can and drain out water from 3 liter can 2 times.

One more

There is an ample supply of milk in a milk tank. You have a 5-liter and a 9-liter cans, both of them unmarked. How can you measure out 2 liters?.

5X + 9Y = 2

X = 4 and Y = -2

50 -> 05 -> 55 -> 19 -> 10 -> 01 -> 51 -> 06 -> 56 -> 29.

done!!