Minimum Path Score Between Cities

Company: Visa

Difficulty: medium

Problem Statement

Minimum Path Score Between Cities Problem Description You are given `n` cities numbered from `1` through `n` and an array `roads`. Each `roads[i] = [a, b, distance]` describes a bidirectional road between cities `a` and `b`. The **score** of a path is the minimum road distance used anywhere along that path. Cities and roads may be visited more than once. Return the minimum possible score of a path from city `1` to city `n`. At least one such path exists. Input Format The first line contains two space-separated integers `n` and `m`, the number of cities and the number of roads. Each of the next `m` lines contains three space-separated integers `a`, `b` and `distance`, describing a bidirectional road between city `a` and city `b` of length `distance`. Output Format Print a single integer: the minimum possible score of a path from city `1` to city `n`. Constraints `2 <= n <= 100000` `1 <= m <= 10000` `1 <= a, b <= n` and `a != b` `1 <= distance <= 10000` More than