Skip to content

Commit cc4aa60

Browse files
committed
Create README - LeetHub
1 parent b9bae3c commit cc4aa60

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

2498-frog-jump-ii/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<h2><a href="https://leetcode.com/problems/frog-jump-ii/">2498. Frog Jump II</a></h2><h3>Medium</h3><hr><p>You are given a <strong>0-indexed</strong> integer array <code>stones</code> sorted in <strong>strictly increasing order</strong> representing the positions of stones in a river.</p>
2+
3+
<p>A frog, initially on the first stone, wants to travel to the last stone and then return to the first stone. However, it can jump to any stone <strong>at most once</strong>.</p>
4+
5+
<p>The <strong>length</strong> of a jump is the absolute difference between the position of the stone the frog is currently on and the position of the stone to which the frog jumps.</p>
6+
7+
<ul>
8+
<li>More formally, if the frog is at <code>stones[i]</code> and is jumping to <code>stones[j]</code>, the length of the jump is <code>|stones[i] - stones[j]|</code>.</li>
9+
</ul>
10+
11+
<p>The <strong>cost</strong> of a path is the <strong>maximum length of a jump</strong> among all jumps in the path.</p>
12+
13+
<p>Return <em>the <strong>minimum</strong> cost of a path for the frog</em>.</p>
14+
15+
<p>&nbsp;</p>
16+
<p><strong class="example">Example 1:</strong></p>
17+
<img alt="" src="https://assets.leetcode.com/uploads/2022/11/14/example-1.png" style="width: 600px; height: 219px;" />
18+
<pre>
19+
<strong>Input:</strong> stones = [0,2,5,6,7]
20+
<strong>Output:</strong> 5
21+
<strong>Explanation:</strong> The above figure represents one of the optimal paths the frog can take.
22+
The cost of this path is 5, which is the maximum length of a jump.
23+
Since it is not possible to achieve a cost of less than 5, we return it.
24+
</pre>
25+
26+
<p><strong class="example">Example 2:</strong></p>
27+
<img alt="" src="https://assets.leetcode.com/uploads/2022/11/14/example-2.png" style="width: 500px; height: 171px;" />
28+
<pre>
29+
<strong>Input:</strong> stones = [0,3,9]
30+
<strong>Output:</strong> 9
31+
<strong>Explanation:</strong>
32+
The frog can jump directly to the last stone and come back to the first stone.
33+
In this case, the length of each jump will be 9. The cost for the path will be max(9, 9) = 9.
34+
It can be shown that this is the minimum achievable cost.
35+
</pre>
36+
37+
<p>&nbsp;</p>
38+
<p><strong>Constraints:</strong></p>
39+
40+
<ul>
41+
<li><code>2 &lt;= stones.length &lt;= 10<sup>5</sup></code></li>
42+
<li><code>0 &lt;= stones[i] &lt;= 10<sup>9</sup></code></li>
43+
<li><code>stones[0] == 0</code></li>
44+
<li><code>stones</code> is sorted in a strictly increasing order.</li>
45+
</ul>

0 commit comments

Comments
 (0)