Tap here to switch tabs
Problem
Submissions

Problem: Minimum Score of a Path Between Two Cities

med
30 min
Try to solve the Minimum Score of a Path Between Two Cities problem.

Statement

You are given a positive integer n representing n cities numbered from 11 to n. You are also given a 22D array roads where roads[i] = [a_i, b_i, distance_i] denotes a bidirectional road connecting city a_i and city b_i with a length equal to distance_i.

The score of a path between two cities is defined as the minimum distance among all roads traversed along that path.

Return the minimum possible score of a path between city 11 and city n.

Note: A path is a sequence of roads between two cities. A path is allowed to visit the same city or traverse the same road multiple times.

Constraints:

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq roads.length ≤105\leq 10^5

  • roads[i].length =3= 3

  • 1≤1 \leq a_i, b_i ≤\leq n

  • a_i ≠\neq b_i

  • 1≤1 \leq distance_i ≤104\leq 10^4

  • There are no repeated edges.

  • There is at least one path between 11 and n.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Score of a Path Between Two Cities

med
30 min
Try to solve the Minimum Score of a Path Between Two Cities problem.

Statement

You are given a positive integer n representing n cities numbered from 11 to n. You are also given a 22D array roads where roads[i] = [a_i, b_i, distance_i] denotes a bidirectional road connecting city a_i and city b_i with a length equal to distance_i.

The score of a path between two cities is defined as the minimum distance among all roads traversed along that path.

Return the minimum possible score of a path between city 11 and city n.

Note: A path is a sequence of roads between two cities. A path is allowed to visit the same city or traverse the same road multiple times.

Constraints:

  • 2≤2 \leq n ≤105\leq 10^5

  • 1≤1 \leq roads.length ≤105\leq 10^5

  • roads[i].length =3= 3

  • 1≤1 \leq a_i, b_i ≤\leq n

  • a_i ≠\neq b_i

  • 1≤1 \leq distance_i ≤104\leq 10^4

  • There are no repeated edges.

  • There is at least one path between 11 and n.