Skip to content

Commit 0a85a78

Browse files
committed
Create README - LeetHub
1 parent ae159af commit 0a85a78

File tree

1 file changed

+41
-0
lines changed
  • 1976-number-of-ways-to-arrive-at-destination

1 file changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<h2><a href="https://leetcode.com/problems/number-of-ways-to-arrive-at-destination">1976. Number of Ways to Arrive at Destination</a></h2><h3>Medium</h3><hr><p>You are in a city that consists of <code>n</code> intersections numbered from <code>0</code> to <code>n - 1</code> with <strong>bi-directional</strong> roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.</p>
2+
3+
<p>You are given an integer <code>n</code> and a 2D integer array <code>roads</code> where <code>roads[i] = [u<sub>i</sub>, v<sub>i</sub>, time<sub>i</sub>]</code> means that there is a road between intersections <code>u<sub>i</sub></code> and <code>v<sub>i</sub></code> that takes <code>time<sub>i</sub></code> minutes to travel. You want to know in how many ways you can travel from intersection <code>0</code> to intersection <code>n - 1</code> in the <strong>shortest amount of time</strong>.</p>
4+
5+
<p>Return <em>the <strong>number of ways</strong> you can arrive at your destination in the <strong>shortest amount of time</strong></em>. Since the answer may be large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
<img alt="" src="https://assets.leetcode.com/uploads/2025/02/14/1976_corrected.png" style="width: 255px; height: 400px;" />
10+
<pre>
11+
<strong>Input:</strong> n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]
12+
<strong>Output:</strong> 4
13+
<strong>Explanation:</strong> The shortest amount of time it takes to go from intersection 0 to intersection 6 is 7 minutes.
14+
The four ways to get there in 7 minutes are:
15+
- 0 ➝ 6
16+
- 0 ➝ 4 ➝ 6
17+
- 0 ➝ 1 ➝ 2 ➝ 5 ➝ 6
18+
- 0 ➝ 1 ➝ 3 ➝ 5 ➝ 6
19+
</pre>
20+
21+
<p><strong class="example">Example 2:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> n = 2, roads = [[1,0,10]]
25+
<strong>Output:</strong> 1
26+
<strong>Explanation:</strong> There is only one way to go from intersection 0 to intersection 1, and it takes 10 minutes.
27+
</pre>
28+
29+
<p>&nbsp;</p>
30+
<p><strong>Constraints:</strong></p>
31+
32+
<ul>
33+
<li><code>1 &lt;= n &lt;= 200</code></li>
34+
<li><code>n - 1 &lt;= roads.length &lt;= n * (n - 1) / 2</code></li>
35+
<li><code>roads[i].length == 3</code></li>
36+
<li><code>0 &lt;= u<sub>i</sub>, v<sub>i</sub> &lt;= n - 1</code></li>
37+
<li><code>1 &lt;= time<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
38+
<li><code>u<sub>i </sub>!= v<sub>i</sub></code></li>
39+
<li>There is at most one road connecting any two intersections.</li>
40+
<li>You can reach any intersection from any other intersection.</li>
41+
</ul>

0 commit comments

Comments
 (0)