I solved this problem using logic,

Walk = A -> C walking time * P

Train = A -> C walking time* P (+) waiting time to board train (+) train travel time * Q (+) D -> B walking time * P

But the logic kept failing

After seeing someone else accepted solution, they just did

Train = Y (+) train travel time * Q (+) D -> B walking time * P

Can anyone help here?

@ssjgz for the rescue

Did he teleport from A -> C to board train, smh :stuck_out_tongue: :slight_smile:

Assume the journey starts at time 0.
If the time taken to get to the train station exceeds Y, then he misses the train.
Otherwise, he has to wait for the train to arrive, which happens at time Y.
So in my solution, max(trainLeaveTime, timeWalkToTrain) will always equal trainLeaveTime (= Y), I think, so I should probably just replace it with trainLeaveTime :slight_smile:


Thanks bro got it.

Basically, it’s the same :stuck_out_tongue:

1 Like