## Amazon Interview Question

Country: United States

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

Let h1 be the time required to climb up to the top of the mountain on the horseback and h2 be the time required to climb down to the bottom on the horseback.

Let p1 and p2 be times required for the person to climb up and climb down on foot.

The person has to make four different kinds of round-trips and measure the round trip times.

1. Climb up and climb down on horseback. The round trip time would be: h1 + h2 = t1 (t1 is measured accurately using the clock at the bottom)
2. Climb up and climb down on foot. The round trip time would be: p1 + p2 = t2
3. Climb up on horseback and climb down on foot. The round trip time would be: h1 + p2 = t3
4. Climb up on foot and climb down on horseback. The round trip time would be: p1 + h2 = t4

Now we have four equations and four unknowns:
h1 + h2 = t1
p1 + p2 = t2
h1 + p2 = t3
p1 + h2 = t4

(t1 to t4 are measured values and hence are known). Solving the system of linear equations gives the values of h1, h2, p1 & p2.

Now start from the bottom of the hill, record the time, call it t, using the clock at the bottom and climb up either on horseback or on foot.

Once you reach the top, correct the clock's time at the top to be either t + h1(if you have climbed up the hill on horseback) or t + p1(if you have climbed up the hill on foot).

Comment hidden because of low score. Click to expand.
3

The equation can not be solved.
Eq1+Eq2-Eq3=Eq4.
Therefore there are four variables but only three independent equations.

Comment hidden because of low score. Click to expand.
0

Yes this won't work.

Comment hidden because of low score. Click to expand.
0

The clock at the top can be sync'ed with the clock at the bottom, only if the time it takes to climb up the mountain is known.

Since there is no way to know the time it takes to climb up the hill, the clocks cannot be synchronized.

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

@Nascent: what do you mean by synchronizing the clock? Can we calculate how much time it takes from top to bottom and from bottom to top?

Comment hidden because of low score. Click to expand.
0

Yes...we can calculate the round trip time of horse... Since bottom clock is correct...we will note the time on bottom clock before horse goes up...then we will note the time on bottom clock when it returns.the difference of these 2 times will be round trip time for horse...

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

If we can assume a constant heart rate,keep monitoring it and then calculate time to reach the top on horse. Add the time it took to the time on bottom clock and set the clock on the top to this time.

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

@Nascent Is it necessary that we have to go to hill only via horse?

Comment hidden because of low score. Click to expand.
0

No

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

can you simply send the horse to the top of the mountain while you record the time it took fir the horse at the bottom. Then you just simply need to record the time in the lower cloch and go on top of the mountain on horseback and set the time.

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

We cannot solve this by using four equations as 4 equations in 4 variables are solvable iff none of the equation is linear combination of others.

Alternative logical approach :
Send the horse up the hill ( now horses can be trained easily )
Go down and call/whistle the horse.
Note the time taken by horse to come down i.e HT.

Now send the horse up again.
When the horse is at the top, note the time of bottom clock i.e. T1. Now, start climbing the hill. When you reach at the top, ride on the horse down the hill.
Note the time at the bottom clock again i.e. T2
=> Time taken by you to climb up the hill and come down on horse = T2-T1
=> time taken by you to climb the hill = T2-T1-time taken to come down on horse = X = T2-T1-HT

Now start from bottom of hill. Note down the time of clock there i.e T. Climb up and set the clock at
the top to T+X.

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

So, accoding to u the horse takes same time down the hill alone and along with the person riding it....

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

test

Comment hidden because of low score. Click to expand.
0
of 2 vote

After calculating the round trip time with the help of the bottom clock, the rider goes up again and sets the clock with an arbitrary time less than the round trip time.

eg:- lets say the round trip time is 35 mins and it takes 20 mins uphill and 15 mins downhill. The rider notes the time at the bottom before he starts say 10:00 . He rides up and assumes it takes 25 mins for him to reach. So he sets the clock to 10.25 and heads down. After coming down the clock reads 10.35 as expected. The top clock now reads 10:40 but since he assumed 10 mins downhill time he thinks its 10:35 and is in sync. To check he goes up again expecting to see a time of 11:00 but surprise he sees 11:05 instead. So he knows he has stepped it up by 5 mins extra the last time and the actual uptime is 20 mins. So he sets 20 mins from 10:35 which is 10:55.

Comment hidden because of low score. Click to expand.
4

Looks to be working on first look. But after thinking about it a bit, I guess there seems to be a mistake.

1. Lets say, The person assumes up/down times as 25/10 instead of the actual 20/15 mins.
2. He Notes the time as 10:00 and starts uphill. Actual time taken is 20mins but he assumes it took 25mins. On reaching he sets the Top clock to 10:25. The Bot clock reads 10:20.
3. He starts downhill and it actually takes 15mins but he assumes it as 10mins. On reaching Bot Clock he finds it to be 10:35 just as expected. The Top Clock should show 10:25+15 = 10:40.
At this point, He may assume that the Top Clock should be 10:25 + 10 = 10:35mins, but its 10:40.
3. Now here's the catch in your solution.
He notes the Bot Clock value as 10:35 and goes up hill which actually takes 20mins.
Now he expects the Top Clock to show 10:35(Bot Reference) + 25mins(assumed uphill time) = 11:00.
The actual Top Clock value will be 10:40(actual value before start of uphill) + 20mins(actual uphil time) = 11:00.
Both his expectation and actual value match which is 11:00, but the actual time shown by the Bot Clock will be 10:35 + 20mins = 10:55.
Not sure how he actually sees 11:05.

Please check and let me know if I missed something.
Otherwise, good thought process.

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

I presume the clock has a seconds hand......synchronize the seconds movement with the snap of your finger....start walking up....keep the time taken in terms of snaps....climb down...keep the count.....verify with the clock once again....climb up and the set the time.....verify once again....if u feel u need more oxygen ....climb up again and the validate the clock on the top of the hill....fare enough....

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

I assume that clocks are only out of synch and the difference remains constant, for e.g. lets say a difference of 10 min, then at 4pm the bottom clock shows 4pm and top clock shows 4.10pm similarly at 8pm the bottom clock shows 8pm and top clock shows 8.10pm.

Comment hidden because of low score. Click to expand.
-2
of 4 vote

There is a solution if one can look at time of top clock from bottom.

Lets say man starts with horse @10 and reaches top and set clock @11 (randomly greater than 10) and starts coming down.
On reaching bottom note the time of the clock at hill top (say its 11:45) to get time taken to come down (which is 45min)
Also note the time of bottom clock which will give him a round trip time (top and back bottom). Say if time now is 12. So round trip time is 2 hrs.
So if round trip time is 2 hrs and time for top to bottom is 45min then time to reach top of hill will be 1hr15min.
He can note the current time and start again climbing the hill and set the correct time.

Correct me if wrong.

Comment hidden because of low score. Click to expand.
0

If it was possible to see the time at top clock from bottom,dont you think he would measure the difference by watching from bottom itself(for example bottom clock has 10:00 and top clock has 10:15) and then just go at the top and shynchronise the clock.

Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0

chg

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.

### 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.