codeanna's blog

By codeanna, history, 18 months ago, In English

In this question https://www.hackerearth.com/problem/algorithm/rescuer-1/description/ 2 for finding the point on x axis say P,where the straight line (joining the two point) cuts on x axis, form a linear equation and put y=0,this will give P but in editorial they use terniary search for finding P and answer is not same. Is my approach correct?? Pls help? Thanks

 
 
 
 
  • Vote: I like it
  • +5
  • Vote: I do not like it

»
18 months ago, # |
  Vote: I like it +8 Vote: I do not like it

You seem to be assuming that it's best for Bob to run in a straight line. But this might not be the case. If Bob is very fast on land and very slow in the water, he wants to go through as little water as possible, even if it means a longer distance.