There are
You start at house forward and backward, each of length queries.
For each house
Traveling clockwise from house forward[i] seconds.
Traveling counterclockwise from house backward[i] seconds.
You need to visit the houses in the sequence given by queries. For each consecutive destination, you can choose to travel either clockwise or counterclockwise along the circle to minimize the travel time.
Return the minimum total time required to visit all houses in the specified order.
Constraints:
forward.length backward.length
forward[i], backward[i]
queries.length
queries[i]
queries[i] queries[i + 1]
queries[0]
There are
You start at house forward and backward, each of length queries.
For each house
Traveling clockwise from house forward[i] seconds.
Traveling counterclockwise from house backward[i] seconds.
You need to visit the houses in the sequence given by queries. For each consecutive destination, you can choose to travel either clockwise or counterclockwise along the circle to minimize the travel time.
Return the minimum total time required to visit all houses in the specified order.
Constraints:
forward.length backward.length
forward[i], backward[i]
queries.length
queries[i]
queries[i] queries[i + 1]
queries[0]