Skip to content

Commit 80eeed7

Browse files
committed
Create README - LeetHub
1 parent bf1be5b commit 80eeed7

File tree

1 file changed

+43
-0
lines changed
  • 1266-minimum-time-visiting-all-points

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<h2><a href="https://leetcode.com/problems/minimum-time-visiting-all-points/">1266. Minimum Time Visiting All Points</a></h2><h3>Easy</h3><hr><div><p>On a 2D plane, there are <code>n</code> points with integer coordinates <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>. Return <em>the <strong>minimum time</strong> in seconds to visit all the points in the order given by </em><code>points</code>.</p>
2+
3+
<p>You can move according to these rules:</p>
4+
5+
<ul>
6+
<li>In <code>1</code> second, you can either:
7+
8+
<ul>
9+
<li>move vertically by one&nbsp;unit,</li>
10+
<li>move horizontally by one unit, or</li>
11+
<li>move diagonally <code>sqrt(2)</code> units (in other words, move one unit vertically then one unit horizontally in <code>1</code> second).</li>
12+
</ul>
13+
</li>
14+
<li>You have to visit the points in the same order as they appear in the array.</li>
15+
<li>You are allowed to pass through points that appear later in the order, but these do not count as visits.</li>
16+
</ul>
17+
18+
<p>&nbsp;</p>
19+
<p><strong class="example">Example 1:</strong></p>
20+
<img alt="" src="https://assets.leetcode.com/uploads/2019/11/14/1626_example_1.PNG" style="width: 500px; height: 428px;">
21+
<pre><strong>Input:</strong> points = [[1,1],[3,4],[-1,0]]
22+
<strong>Output:</strong> 7
23+
<strong>Explanation: </strong>One optimal path is <strong>[1,1]</strong> -&gt; [2,2] -&gt; [3,3] -&gt; <strong>[3,4] </strong>-&gt; [2,3] -&gt; [1,2] -&gt; [0,1] -&gt; <strong>[-1,0]</strong>
24+
Time from [1,1] to [3,4] = 3 seconds
25+
Time from [3,4] to [-1,0] = 4 seconds
26+
Total time = 7 seconds</pre>
27+
28+
<p><strong class="example">Example 2:</strong></p>
29+
30+
<pre><strong>Input:</strong> points = [[3,2],[-2,2]]
31+
<strong>Output:</strong> 5
32+
</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>points.length == n</code></li>
39+
<li><code>1 &lt;= n&nbsp;&lt;= 100</code></li>
40+
<li><code>points[i].length == 2</code></li>
41+
<li><code>-1000&nbsp;&lt;= points[i][0], points[i][1]&nbsp;&lt;= 1000</code></li>
42+
</ul>
43+
</div>

0 commit comments

Comments
 (0)