Minimum time traversal

In this problem i am not able to understand how the output for sample input

3

20 20 100 100

35 35 50 50 0

30 30 25 25 0

40 40 60 60 100

is #3 : 120.

According to my calculation it should be 130.

hello @vkth

from 20 20 to 25 25 -> time 10
then 25 25 to 30 30 -> time 0
then 30 30 to 35 35 -> time 10
then 35 35 to 50 50 -> time 0
then 50 50 to 100 100 -> time 100

total time=10+0+10+100 =>120

5
200 200 800 800
250 250 799 798 100
551 551 799 799 31
2 2 99 99 15
3 2 550 550 30
100 100 199 199 10

Can you please explain for this one as well? According to me it should be 203.

hello @vkth
there will be so many possible cases. it is better to test your logic on given sample test case and code it.

analysing all possibilities manually is bit cumbersome.

Hai!
I did code on the basis of my understanding, it has passed the sample test cases and many other test cases. However, Since all of them didn’t pass, I tried to analyse if there is an issue with my approach by looking at the failing test cases. But, am not able to figure out issue. That is why I asked you to explain the above test case. According to me, there is no way it has 95 as its answer, it should be 203.

please share ur code i will check

pls refer this code.
maybe this help u in debugging.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Thank you so much. This helped :))