Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Arrive at Destination

Try to solve the Number of Ways to Arrive at Destination problem.

Statement

You are in a city consisting of n intersections numbered from 00 to n −1- 1, connected by bidirectional roads. You are given an integer n and a 22D integer array roads where roads[i] =[ui,vi,timei]= [u_i, v_i, {time}_i] indicates a bidirectional road between intersections uiu_i and viv_i that takes timei{time}_i minutes to traverse.

You want to travel from intersection 00 to intersection n −1- 1 in the shortest amount of time.

Return the number of ways to reach intersection n −1- 1 from intersection 00 in the minimum possible travel time. Since the answer may be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤200\leq 200

  • n −1≤- 1 \leq roads.length ≤‘n‘×(‘n‘−1)2\leq \frac{ {`n`} \times ( {`n`} - 1)}{2}

  • roads[i].length =3= 3

  • 0≤ui,vi≤0 \leq u_i, v_i \leq n −1- 1

  • 1≤timei≤1091 \leq {time}_i \leq 10^9

  • ui≠viu_i \neq v_i

  • There is at most one road connecting any two intersections.

  • You can reach any intersection from any other intersection.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Arrive at Destination

Try to solve the Number of Ways to Arrive at Destination problem.

Statement

You are in a city consisting of n intersections numbered from 00 to n −1- 1, connected by bidirectional roads. You are given an integer n and a 22D integer array roads where roads[i] =[ui,vi,timei]= [u_i, v_i, {time}_i] indicates a bidirectional road between intersections uiu_i and viv_i that takes timei{time}_i minutes to traverse.

You want to travel from intersection 00 to intersection n −1- 1 in the shortest amount of time.

Return the number of ways to reach intersection n −1- 1 from intersection 00 in the minimum possible travel time. Since the answer may be large, return it modulo 109+710^9 + 7.

Constraints:

  • 1≤1 \leq n ≤200\leq 200

  • n −1≤- 1 \leq roads.length ≤‘n‘×(‘n‘−1)2\leq \frac{ {`n`} \times ( {`n`} - 1)}{2}

  • roads[i].length =3= 3

  • 0≤ui,vi≤0 \leq u_i, v_i \leq n −1- 1

  • 1≤timei≤1091 \leq {time}_i \leq 10^9

  • ui≠viu_i \neq v_i

  • There is at most one road connecting any two intersections.

  • You can reach any intersection from any other intersection.