ServiceNow interview question

Leet Code - Write code and explain for "Minimum Time to Complete Trips"