Had anyone solved Train or Walk problem. Problem-code : WALKFAST

Problem Link

Please tell me the solution.

I tried a lot to solve it.

As the problem says consider 2 cases one by walk alone and other by train and walk(if D != B) , take the minimum of the 2 time…you just need to consider some corner cases…