You are in a city with n
intersections (numbered from 0
to n - 1
) connected by bidirectional roads. Each road connects two intersections u
and v
and takes time
minutes to travel.
You are given:
- An integer
n
— the number of intersections - A 2D array
roads
where each entry is[u, v, time]
Your goal is to determine how many different ways you can travel from intersection 0
(source) to intersection n - 1
(destination) in the shortest possible time.
Return the number of such shortest paths modulo 10⁹ + 7
.