Interview Question


Country: United States




Comment hidden because of low score. Click to expand.
1
of 1 vote

If you move to the next one every time, the oddness between you and the monkey doesn't change, so if you miss the monkey in one traversal, the number of trees between you and the monkey must be even(like you are shoting at#1 while monkey is on tree #2). So if one pass fail, shot at the same tree and change the number of trees between you and monkey to odd, do one more pass and you can't miss it

- Anonymous February 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice!

- Chih.Chiu.19 February 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

shot next to tree on which monkey is sitting..........

- alone February 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What if u start from the middle ? Tree number 3. If you shoot at tree 3 . Then you have 3 posibilities :
-- you killed the monkey
-- the monkey is in the tree 1 or 2. Next shooting will be at tree 2.
-- the monkey is in the tree 4 or 5. Next shooting will be at tree 4.

So the maximum number of times you will have to shoot will be 3. When you start with tree 3 the monkey will be scared to jump through tree number 3.

- Kamy February 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

That would mean you'd have to be able to see the monkey. Then, why not just shoot the tree he's in?

- Steven February 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I considered that the monkey is moving all the time, but she gets scared and tries to go far away from the shooting. So if u see it in tree 2 and shoot tree 2 she can move to 1 or 3 in that time (so she gets away). I tried to narrow her options.

- Kamy February 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

+ no one said that I can't see the monkey :P

- Kamy February 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

My understanding is that the monkey moves at the same time when you shoot --- namely, you "name" the tree you want to shoot, then the monkey moves at random. One confusion for me is that you did not specify whether the monkey can stay still or it *has* to move each time I shoot --- the second case is easier.
2nd case)
You shoot at the side where there are more trees, for example, if the monkey is at tree 2 you shoot at tree 3, then the monkey can either be killed or move to tree 1, then you shoot at tree 2 to kill it.
1st case)
If the monkey can stand still, you still shoot to the tree next to it. For example, if the monkey is on tree 2 you shoot at tree 3. Then the monkey will have a 1/3 chance to be killed by this shot (we assume this is not a cut scene from Matrix and the monkey cannot see where the bullet goes), and you keep continue doing so, and eventually when the monkey is at tree 1, it will have a 1/2 chance to be killed by each shot.

- Zhi Qiu February 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

1. You can not see monkey
2. Monkey has to move either way. if you shot same tree then dead.
3. How we find out which side monkey is ??

- MI February 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Thanks for the clarification, now I am clear and a solution I can think of is the following, and by step I mean if the monkey is not killed by previous attempts.

1) Shoot at 4 twice. Then monkey can only be currently in 1, 2, and 3.
2) Shoot at 3 once. Then monkey can only be currently in 1, 2, and 4.
3) Shoot at 2 once. Then monkey can only be currently in 1, 3, and 5.
4) Shoot at 4 once. Then monkey can only be in 2.
5) Kill the monkey whatever way you want.

- Chih.Chiu.19 February 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Point 2 fail .. if monkey at 2 . you shot once at 3. monkey can jump to 3.so after once shot at 3 monkey can be at 3 also

- MI February 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is where the confusion begins: we have to agree on a convension whether the monkey moves *before* or *after* the shot --- here I assume the monkey moves first though I cannot see it. Then my solution is correct.

- Chih.Chiu.19 February 07, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Shoot 2, 3, 4, 4, 3, 2 and the monkey is dead.

- Anonymous February 10, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More